-
Notifications
You must be signed in to change notification settings - Fork 0
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
[8164] apps/ai_reports: connect with external API #54
Conversation
goapunk
commented
May 30, 2024
- add a celery task which sends a comment to the XAI server and saves the response as AiReport
- connect comment post_save signal with celery task
- rename category to label to be in line with the XAI response
- change AiReport fields to JSONField for now
- add tests
d97bf33
to
d3d8ea0
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.
thank you, some small improvements and will be good to go!
apps/ai_reports/signals.py
Outdated
if getattr(settings, "XAI_API_URL", None): | ||
comment_text_changed = getattr(instance, "_former_comment") != getattr( | ||
instance, "comment" | ||
) |
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.
shouldn't use here the update_fields
to check what's has been updated?
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 far as I understand update_fields
can be:
None
- > everything will be savedA list of fields
-> only the fields in the list will be savedEmpty list
-> nothing will be saved
So we can't get rid of the check in L19 as we don't know if the text changed in case 1
d3d8ea0
to
bb9f31b
Compare
e533682
to
103582a
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.
An extra test is needed to make sure the perform_update
view calls the post_save() signal
) | ||
if created or comment_text_changed: | ||
# FIXME: use delay_on_commit() once updated to celery 5.x | ||
get_classification_for_comment.delay(instance.pk) |
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.
the update needs a test for when comment is updated via the views, which comes from django rest api, and not sure if it performs an object save or update query. We only have a GET request test in tests/moderatorfeedback/test_moderator_comment_feedback_api.py
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.
added some tests
103582a
to
c09a972
Compare
- add a celery task which sends a comment to the XAI server and saves the response as AiReport - connect comment post_save signal with celery task - rename category to label to be in line with the XAI response - change AiReport fields to JSONField for now - add tests - **BREAKING CHANGE** Reset migrations for the ai_reports app (see changelog)
c09a972
to
e2cf219
Compare
@m4ra I also added manual migrations so we don't need to wipe the database for the ai_reports app, as there already was some manually created content on dev |
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.
very nice, thank you!