~qeef/damn-server

The server side of the damn project.
Fix db query for list of geometries since
Add since to geometries endpoint
Make lang code always lower-case

refs

master
browse  log 
v0.18.1
release notes 

clone

read-only
https://git.sr.ht/~qeef/damn-server
read/write
git@git.sr.ht:~qeef/damn-server

You can also use your local clone with git send-email.

builds.sr.ht status

#Damn server

Divide and map. Now. -- the damn project -- helps mappers by dividing some big area into smaller squares that a human can map.

damn_server provides access to the database via JSON API.

#License

The project is published under AGPLv3 License.

#Contribute

#Discuss

Join the general discussion in the damn-project mailing list. Read the code of conduct and the mailing list etiquette.

Use damn-dev mailing list to send a patch and damn-sec mailing list to report security issues.

#Code

This project uses procedural programming paradigm. Please, do not invent new classes.

Write great git commit messages:

  1. Separate subject from body with a blank line.
  2. Limit the subject line to 50 characters.
  3. Capitalize the subject line.
  4. Do not end the subject line with a period.
  5. Use the imperative mood in the subject line.
  6. Wrap the body at 72 characters.
  7. Use the body to explain what and why vs. how.

When adding feature or hotfix, use Test-driven development (TDD):

  1. Add tests to tests directory. Unit test names start with test_....
  2. Run tests (python3 -m unittest discover tests), check that tests fail.
  3. Code now. Implement functionality.
  4. Run tests again, check that tests pass.
  5. Refactor.

You may also need to run integration tests:

  1. Update api.py with endpoint, integration.py with integration test.
  2. Run damn server with uvicorn damn_server.api:app --workers 9.
  3. Run integration tests with python3 -m unittest tests/integration.py.

Note: Run tests only with no records in the database. All the records from the database are deleted when the tests are finished.

Note: Both tests can be run with PYTHONASYNCIODEBUG=1 before command. It is recommended to do so, because it shows the Python async debug information.

Note: You can run tests and uvicorn in a virtual environment. You can create a virtual environment with:

python3 -m venv tve
. tve/bin/activate
pip install -r requirements.txt

Note: Coverage report includes the results of the area, list_of, new, square, and user unit tests only.

#Set up the database

The damn_server is API to the database, so you need the database to develop the damn_server.

You can install postgresql with postgis extension and use damndb docker image config files from damn-deploy repository.

Or you can use damndb docker image from damn-deploy repository:

git clone https://git.sr.ht/~qeef/damn-deploy
cd damn-deploy
sed -i '/POSTGRES_PASSWORD=.*/d' .env
docker-compose up db

Then get the IP address of damndb:

export DB_HOST=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' damndb)

Finally, create virtual environment and run unit tests:

python3 -m venv tve
. tve/bin/activate
pip install -r requirements.txt
PYTHONASYNCIODEBUG=1 python3 -m unittest discover tests

See the Code section to run integrations tests.

#Documentation

The developer's documentation is in docs directory and generated by the Sphinx. API documentation is generated autmatically.