Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement deletion policy #464

Merged
merged 91 commits into from
Aug 1, 2024
Merged

Implement deletion policy #464

merged 91 commits into from
Aug 1, 2024

Conversation

matthiasschaub
Copy link
Collaborator

@matthiasschaub matthiasschaub commented Jun 10, 2024

Todo:

  • delete bbox on non-consent
  • should Bbox class have from string (from wkt function)?
  • uncomment esri layer
  • check if autovacuum is enabled
  • Fix tests by setup database on each run (not just on writing into the database)

This PR implements two cleanup functions as well as stores more metadata in the database:

  1. cleanup_map_frames: Cleanup of old map frames for which there are uploaded sketch maps without consent. This cleanup is executed by celery beat every hour.
  2. cleanup_blobs: Cleanup of uploaded sketch maps without consent after vector and raster results are generated. This cleanup is executed as callback by celery after uploaded sketch maps are processed.
  3. Store map generation parameter in the database

Possible improvements:

  • client_celery.select_file call in tasks.py should return not only the file but also layer and bbox. This would enable to load those only at the place needed and not in routes.py and pass it to tasks.py. (locality of behaviour)
  • avoid code duplication in database clients
  • maybe rename select_file() to a more specific name since it does not only return file

Closes #447

@matthiasschaub matthiasschaub changed the title Delete policy Overhaul consent and implement delete policy Jun 10, 2024
@matthiasschaub matthiasschaub marked this pull request as ready for review June 13, 2024 08:13
@matthiasschaub matthiasschaub changed the title Overhaul consent and implement delete policy Implement delete policy Jun 13, 2024
@matthiasschaub matthiasschaub changed the title Implement delete policy Implement deletion policy Jun 13, 2024
create_query = """
CREATE TABLE IF NOT EXISTS blob(
id SERIAL PRIMARY KEY,
uuid UUID,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to something like map_frame_uuid or map_uuid

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


Only set file and name to null. Keep metadata.
"""
# TODO: Wait one day until deletion or check celery task status?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

either implement ts interval of 24 hours or delete only for one uuid

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented delete by map frame uuid.

@@ -17,6 +17,16 @@ class Bbox:
lon_max: float
lat_max: float

@property
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add test function

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

def cleanup_map_frames():
"""Cleanup map frames stored in the database."""
db_client_celery.cleanup_map_frames()
# TODO: run Vacuum or Vacuum full?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolve before merging

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Autovacuum should be enabled by default. Check first. If so, this should be enough.

Copy link
Member

@joker234 joker234 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some recommendations:

  • mock arcgis request in definitions.py
  • remove .gitattributes
  • link config.py (defaults) in documentation

@matthiasschaub
Copy link
Collaborator Author

matthiasschaub commented Aug 1, 2024

some recommendations:

* mock arcgis request in `definitions.py`

* remove `.gitattributes`

* link config.py (defaults) in documentation

All of those has been addressed.

@matthiasschaub matthiasschaub merged commit 4d8e329 into main Aug 1, 2024
1 check passed
@matthiasschaub matthiasschaub deleted the delete-policy branch August 1, 2024 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

backend: replace oqt.ohsome.org
3 participants