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

Replace storage.create_annotation with an AnnotationWriteService #7966

Merged
merged 4 commits into from
May 4, 2023

Conversation

jon-betts
Copy link
Contributor

@jon-betts jon-betts commented May 3, 2023

For:

Requires:

Testing notes

For H / Via / ViaHTML / Client:

make service
make dev


return annotation

def _validate_group(self, annotation: Annotation):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is structured a bit differently from the original service, as the create and update methods were doing nearly the same thing. Pushing more functionality here allows it to be tested once and re-used.


self._search_index_service._queue.add_by_id( # pylint: disable=protected-access
annotation.id, tag="storage.create_annotation", schedule_in=60
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why is the queue private?

)._queue.add_by_id(annotation.id, tag="storage.create_annotation", schedule_in=60)

return annotation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As the _validate_group method is still used by update_annotation we don't get a size reduction proportionate to those we added. In the next PR when we remove the update method, a lot more should go.

"links_service",
"annotation_json_service",
"storage",
)
class TestCreate:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've rewritten these tests as they were written in the style where every aspect of the method had it's own test, which made it very long.

@jon-betts jon-betts self-assigned this May 3, 2023
@jon-betts jon-betts changed the title Add AnnotationWriteService with create annotation method Replace storage.create_annotation with an AnnotationWriteService method May 3, 2023
@jon-betts jon-betts changed the title Replace storage.create_annotation with an AnnotationWriteService method Replace storage.create_annotation with an AnnotationWriteService May 3, 2023
@jon-betts jon-betts removed the WIP label May 3, 2023
@jon-betts jon-betts requested a review from marcospri May 3, 2023 19:41
Copy link
Member

@marcospri marcospri left a comment

Choose a reason for hiding this comment

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

Same behavior as before and a nicer approach for the service and the tests 👍

@@ -78,7 +79,9 @@ def create(request):
schema = CreateAnnotationSchema(request)
appstruct = schema.validate(_json_payload(request))

annotation = storage.create_annotation(request, appstruct)
annotation = request.find_service(AnnotationWriteService).create_annotation(
data=appstruct
Copy link
Member

@marcospri marcospri May 4, 2023

Choose a reason for hiding this comment

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

I've seen this name before (appstruct) in the H code base and not sure what it means.

I wound't change it now thought. It's probably "idiomatic H".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah it probably is, but I agree it's off-putting.

db_session=request.db,
has_permission=request.has_permission,
search_index_service=request.find_service(
# pylint: disable=protected-access
Copy link
Member

Choose a reason for hiding this comment

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

What line is the disable targeting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think something has gotten lost in the merging here...

Base automatically changed from anno-read-svc-fetch-all to main May 4, 2023 16:20
@jon-betts jon-betts merged commit 2a13d77 into main May 4, 2023
@jon-betts jon-betts deleted the anno-write-svc-create branch May 4, 2023 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants