-
-
Notifications
You must be signed in to change notification settings - Fork 48
send follow immediately #1091
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
send follow immediately #1091
Conversation
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.
Hello @alphatownsman, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
This pull request introduces changes to the Follow
model and related utilities to manage the state of follow requests more effectively. It adds new fields to the Follow
model, specifically state_next_attempt
and state_locked_until
, and modifies the update_follow_state
and follow
methods to use a centralized Takahe.update_state
method for updating the state of various objects, including Follow
objects. This change ensures consistency when updating the state of follow requests.
Highlights
- Model Changes: Adds
state_next_attempt
andstate_locked_until
fields to theFollow
model intakahe/models.py
and the corresponding migration filetakahe/migrations/0001_initial.py
. - State Management: Refactors
update_follow_state
andTakahe.follow
intakahe/utils.py
to useTakahe.update_state
for updating the state ofFollow
objects, promoting consistency. - Centralized State Update: Extends
Takahe.update_state
intakahe/utils.py
to handleFollow
objects, centralizing state update logic for various models.
Changelog
- takahe/migrations/0001_initial.py
- Added
state_next_attempt
field as a DateTimeField with blank=True and null=True (line 916). - Added
state_locked_until
field as a DateTimeField with blank=True, null=True, and db_index=True (lines 918-920).
- Added
- takahe/models.py
- Added
state_next_attempt
field as a DateTimeField with blank=True and null=True (line 893). - Added
state_locked_until
field as a DateTimeField with null=True, blank=True, and db_index=True (line 894).
- Added
- takahe/utils.py
- Modified
update_follow_state
to useTakahe.update_state
for updating the follow state (line 262). - Modified
Takahe.follow
to useTakahe.update_state
when the follow state is not 'accepted' (line 270). - Updated
Takahe.update_state
to includeFollow
objects in the object type annotation (line 694).
- Modified
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
A follow's state,
A change of time it does await,
Locked until then.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
The pull request introduces new fields to the Follow
model and updates the update_state
function to include the Follow
model. It also modifies the update_follow_state
and follow
methods in Takahe
to use the update_state
function. Overall, the changes seem reasonable, but there are a few points that need clarification and improvement.
Summary of Findings
- Missing documentation for new fields: The pull request adds
state_next_attempt
andstate_locked_until
fields to theFollow
model, but there is no documentation explaining their purpose or usage. This could make it difficult for other developers to understand and use these fields correctly. - Potential race condition in
update_state
: Theupdate_state
function updates thestate_changed
field totimezone.now()
. If multiple instances try to update the state at the same time, there could be a race condition, leading to lost updates. Consider usingauto_now=True
in the model definition or usingF
expressions to avoid race conditions.
Merge Readiness
The pull request introduces important changes related to follow state management. While the code seems functional, the lack of documentation for the new fields and the potential race condition in update_state
need to be addressed before merging. I am unable to approve this pull request, and recommend that it not be merged until those issues are addressed (at a minimum). Please have others review and approve this code before merging.
): | ||
obj.state = state | ||
obj.state_changed = timezone.now() |
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.
Consider using F
expressions to update state_changed
to avoid potential race conditions if multiple instances try to update the state at the same time. Alternatively, using auto_now=True
in the model definition would automatically update the timestamp on each save.
from django.db.models import F
obj.state = state
obj.state_changed = timezone.now()
obj.state_changed = F('state_changed') # add this line
obj.save()
state_next_attempt = models.DateTimeField(blank=True, null=True) | ||
state_locked_until = models.DateTimeField(null=True, blank=True, db_index=True) |
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.
No description provided.