Skip to content

Conversation

@pcrespov
Copy link
Member

@pcrespov pcrespov commented Oct 23, 2024

What do these changes do?

A project can now be marked as trashed (POST /projects/{id}:trash) or restored from the trash (POST /projects/{id}:untrash). Trashing a project flags it for deletion after the defined retention period elapses (PROJECTS_TRASH_RETENTION_DAYS).

This is a view of new entrypoints
image

When listing projects GET /projects?filters={"trashed": true}, you can now filter out trashed items. Those would correspond to the items in the trash bin. By default, trashed projects are excluded from the list, i.e. GET /projects won't list trashed projects. The project object in the response includes new fields indicating whether a project is trashed (trashedAt=null) and the date it was trashed (trashedAt!=null).

The retention policy for trashed projects is controlled at the application level through the PROJECTS_TRASH_RETENTION_DAYS setting. This value is also available via the app's static configuration REST API endpoint. SEE image

Highlights

  • web-API 0.43.1 → 0.44.0
    • Added trash tag in openapi.yaml:
      • Supports trashing projects
      • Exposes "empty trash" (not yet implemented)
      • Introduces new filter for listings
      • Added a new field in the GET object response
    • Refer to web/server/tests/unit/with_dbs/03/test_trash.py for usage examples
  • 🗃️ Database
    • Added a trashed_at timestamp column in the projects table
  • Garbage Collection (GC)
    • Added a background "prune task" to automatically delete trashed items after their expiration date
    • Task is defined but the service has not been implemented yet
  • Application Settings
    • New configuration option: PROJECTS_TRASH_RETENTION_DAYS
    • Exposed as part of the static config entrypoint

NOTE: this is now it would be curled

curl -G "http://your-api-url.com/v0/projects" --data-urlencode 'filters={"trashed": true}'
curl -G "http://your-api-url.com/v0/projects?filters=%7B%22trashed%22%3A%20true%7D"

Related issue/s

  • implements ITISFoundation/private-issues#6

How to test

cd services/web/server
make install-dev
pytest -vv tests/unit/with_dbs/*/*trash*.py

Dev-ops checklist

@pcrespov pcrespov added the a:webserver webserver's codebase. Assigning the area is particularly useful for bugs label Oct 23, 2024
@pcrespov pcrespov added this to the MartinKippenberger milestone Oct 23, 2024
@pcrespov pcrespov self-assigned this Oct 23, 2024
@codecov
Copy link

codecov bot commented Oct 23, 2024

Codecov Report

Attention: Patch coverage is 93.02326% with 15 lines in your changes missing coverage. Please review.

Project coverage is 87.87%. Comparing base (fe95d75) to head (5b94385).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6579      +/-   ##
==========================================
+ Coverage   87.75%   87.87%   +0.12%     
==========================================
  Files        1552     1555       +3     
  Lines       62361    62559     +198     
  Branches     2085     2085              
==========================================
+ Hits        54724    54974     +250     
+ Misses       7319     7267      -52     
  Partials      318      318              
Flag Coverage Δ
integrationtests 64.80% <70.40%> (+1.11%) ⬆️
unittests 85.80% <83.25%> (-0.03%) ⬇️
Components Coverage Δ
api ∅ <ø> (∅)
pkg_aws_library 93.38% <ø> (ø)
pkg_dask_task_models_library 96.87% <ø> (ø)
pkg_models_library 92.14% <100.00%> (+0.01%) ⬆️
pkg_notifications_library 83.79% <ø> (ø)
pkg_postgres_database 87.77% <ø> (ø)
pkg_service_integration 71.44% <ø> (ø)
pkg_service_library 76.69% <0.00%> (ø)
pkg_settings_library 91.42% <ø> (ø)
pkg_simcore_sdk 85.27% <ø> (ø)
agent 97.16% <ø> (ø)
api_server 89.82% <ø> (ø)
autoscaling 95.26% <ø> (ø)
catalog 89.51% <ø> (ø)
clusters_keeper 98.85% <ø> (ø)
dask_sidecar 91.30% <ø> (ø)
datcore_adapter 94.02% <ø> (ø)
director 58.38% <ø> (-0.05%) ⬇️
director_v2 90.83% <ø> (-0.02%) ⬇️
dynamic_scheduler 96.62% <ø> (ø)
dynamic_sidecar 89.70% <ø> (ø)
efs_guardian 87.03% <ø> (ø)
invitations 93.47% <ø> (ø)
osparc_gateway_server 85.15% <ø> (ø)
payments 93.08% <ø> (ø)
resource_usage_tracker 87.36% <ø> (ø)
storage 89.73% <ø> (ø)
webclient ∅ <ø> (∅)
webserver 89.30% <93.36%> (+0.40%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fe95d75...5b94385. Read the comment docs.

@pcrespov pcrespov added the a:database associated to postgres service and postgres-database package label Oct 24, 2024
@pcrespov pcrespov changed the title WIP:♻️ Is468/trash api ✨ Trash projects Oct 24, 2024
@pcrespov pcrespov marked this pull request as ready for review October 24, 2024 09:46
@pcrespov pcrespov requested a review from odeimaiz October 24, 2024 09:46
Copy link
Member

@odeimaiz odeimaiz left a comment

Choose a reason for hiding this comment

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

What happens if a delete a folder? And if I then untrash a study within that folder?

Copy link
Collaborator

@matusdrobuliak66 matusdrobuliak66 left a comment

Choose a reason for hiding this comment

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

Thanks, I left some comments

Copy link
Member

@sanderegg sanderegg left a comment

Choose a reason for hiding this comment

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

nice, a few comments that we can discuss

@pcrespov
Copy link
Member Author

What happens if a delete a folder? And if I then untrash a study within that folder?

Clarified offline.

Copy link
Member

@sanderegg sanderegg left a comment

Choose a reason for hiding this comment

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

ok. this will open many doors to many new issues. let's see.

@sonarqubecloud
Copy link

@pcrespov pcrespov merged commit 3ec9333 into ITISFoundation:master Oct 28, 2024
86 of 88 checks passed
@pcrespov pcrespov deleted the is468/trash-api branch October 28, 2024 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a:database associated to postgres service and postgres-database package a:webserver webserver's codebase. Assigning the area is particularly useful for bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants