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

Task to fill up the AnnotationSlim table in the background #8269

Merged
merged 1 commit into from
Oct 25, 2023

Conversation

marcospri
Copy link
Member

@marcospri marcospri commented Oct 19, 2023

Testing

  • Make some annotations
  • Truncate the slim table
    docker compose exec postgres psql -U postgres -c "truncate annotation_slim cascade"
  • Run then new task, on make shell:
In [1]: from h.tasks.annotations import fill_annotation_slim

In [2]: fill_annotation_slim.delay()
Out[2]: <AsyncResult: a64c0f1a-e98b-450b-a9aa-aea4998cee9a>
  • Wait for the task to fiinish on make dev logs:
    Task h.tasks.annotations.fill_annotation_slim[a64c0f1a-e98b-450b-a9aa-aea4998cee9a] succeeded in 0.02210914299939759s: None

  • Query the created slim records

docker compose exec postgres psql -U postgres -c "select * from annotation_slim"

@marcospri marcospri marked this pull request as draft October 19, 2023 13:49
@marcospri marcospri marked this pull request as ready for review October 23, 2023 08:58
@marcospri marcospri requested a review from seanh October 23, 2023 09:02
.outerjoin(AnnotationSlim)
.outerjoin(AnnotationModeration)
.where(AnnotationSlim.id.is_(None))
.order_by(Annotation.created.asc())
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm thinking it maybe be best to sort by desc, have the most recent ones here will be useful sooner than the old ones from years ago.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 Might want to use updated instead too

.outerjoin(AnnotationSlim)
.outerjoin(AnnotationModeration)
.where(AnnotationSlim.id.is_(None))
.order_by(Annotation.created.asc())
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 Might want to use updated instead too

SQL based, a CTE selects all the data for the annotation slim table that
an INSERT adds to the slim table.

This reverts commit b6301df.
@marcospri marcospri merged commit 97f0ed5 into main Oct 25, 2023
9 checks passed
@marcospri marcospri deleted the fill-slim-task branch October 25, 2023 11:11
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