-
Notifications
You must be signed in to change notification settings - Fork 426
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
Conversation
|
||
return annotation | ||
|
||
def _validate_group(self, annotation: Annotation): |
There was a problem hiding this comment.
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 | ||
) |
There was a problem hiding this comment.
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 | ||
|
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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.
123f4d9
to
6dd5530
Compare
AnnotationWriteService
with create annotation methodstorage.create_annotation
with an AnnotationWriteService
method
storage.create_annotation
with an AnnotationWriteService
methodstorage.create_annotation
with an AnnotationWriteService
6dd5530
to
6c02aa7
Compare
6c02aa7
to
85e6b8d
Compare
There was a problem hiding this 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 |
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
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.
h/services/annotation_write.py
Outdated
db_session=request.db, | ||
has_permission=request.has_permission, | ||
search_index_service=request.find_service( | ||
# pylint: disable=protected-access |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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...
d4bf030
to
c124650
Compare
85e6b8d
to
f06bb09
Compare
f06bb09
to
aa848a2
Compare
For:
Requires:
storage.fetch_ordered_annotation
with anAnnotationReadService
method #7948Testing notes
For H / Via / ViaHTML / Client: