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

Allow to add annotations to the job queue by ID #9269

Merged
merged 1 commit into from
Jan 27, 2025
Merged

Conversation

marcospri
Copy link
Member

@marcospri marcospri commented Jan 23, 2025

For: #8727

Instead of writing a one off script or sql query to add the remaining annotations missing in annotation_slim we add a new option on the H admin pages to be able to add annotations by ID.

Testing

  • First remove all annotation_slim rows

In make sql:

truncate cascades to table "annotation_metadata"
select id from annotation limit 1;
                  id                  
--------------------------------------
 cdff42be-2fc0-11ef-ae06-37653ab647c1
(1 row)
  • Use that annotation ID on the textarea, select "Annotation Slim" as the job type

  • Process pending jobs locally, in make shell

from h.tasks.annotations import sync_annotation_slim
sync_annotation_slim.delay(limit=10)
  • Check the annotations has correctly being sync-ed to annotation_slim:
select * from annotation_slim
postgres-# ;
 id  |                pubid                 |          created          |          updated          | deleted | moderated | shared | document_id | user_id | group_id 
-----+--------------------------------------+---------------------------+---------------------------+---------+-----------+--------+-------------+---------+----------
 572 | cdff42be-2fc0-11ef-ae06-37653ab647c1 | 2024-06-21 11:24:20.72035 | 2024-06-21 11:24:20.72035 | f       | f         | t      |          16 |     228 |       29
(1 row)

@marcospri marcospri marked this pull request as ready for review January 23, 2025 11:12
@marcospri marcospri requested a review from mtomilov January 23, 2025 11:12
@@ -10,7 +10,8 @@ class Priority:
SINGLE_ITEM = 1
SINGLE_USER = 100
SINGLE_GROUP = 100
BETWEEN_TIMES = 1000
BETWEEN_TIMES = 1_000
Copy link
Member Author

Choose a reason for hiding this comment

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

Use the thousands separator.

New property alias for "by_ids"

annotation_ids = []
for annotation_id in ids:
# If the ID looks like an hex UUID, convert it to URL-safe
if len(annotation_id) == 36:
Copy link
Member Author

Choose a reason for hiding this comment

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

The first use case for this (complete the annotation_slim job) will use the full UUID format as the IDs come directly from the DB.

I think it's just nicer to support both formats anyway.

application-level URL-safe format
"""
where = [Annotation.id.in_(annotation_ids)]
self.add_where(name, where, tag, Priority.BY_IDS, force, schedule_in)
Copy link
Contributor

Choose a reason for hiding this comment

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

A minor thing but maybe it's worth passing the last two as keyword arguments like we do in add_annotations_by_ids.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, done.

Copy link
Contributor

@mtomilov mtomilov left a comment

Choose a reason for hiding this comment

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

Looks good

@marcospri marcospri merged commit 7d86354 into main Jan 27, 2025
10 checks passed
@marcospri marcospri deleted the admin-queue-by-ids branch January 27, 2025 13:03
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.

2 participants