-
-
Notifications
You must be signed in to change notification settings - Fork 72
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
feat: Add Pull Request model and integrate with sync_repository #845
base: main
Are you sure you want to change the base?
feat: Add Pull Request model and integrate with sync_repository #845
Conversation
e92aef2
to
c56972a
Compare
c56972a
to
0aff313
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.
Great PR, please look into these when you get a chance:
35bfb89
to
022555a
Compare
ded2dc4
to
6f7b568
Compare
6f7b568
to
181ec78
Compare
181ec78
to
ad3fe10
Compare
@arkid15r Please Don't Forget this PR! |
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 have 2 suggestions to address before the merge:
- DRY code for issues/prs
- streamline PR sync process logic
@@ -83,6 +84,56 @@ def sync_repository(gh_repository, organization=None, user=None): | |||
else: | |||
logger.info("Skipping issues sync for %s", repository.name) | |||
|
|||
if not repository.is_archived and repository.project: |
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 suggest applying the same logic we use for issues sync (see above). It fetches all
states and has a cut off date if it's not the very first sync.
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.
You are talking about that since
argument passed to **kwargs in issue?
If you are then since
is not available in PR!
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.
Let's try fetching PRs sorted by updated
and break the loop when we see a date earlier than our latest_updated_at
(if any)?
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.
We can sort by the created-at
field to retrieve the earliest date after the first fetch is complete. For subsequent runs, we can use this date. If the closed pull request’s date is older than the stored date, we can simply skip it.
from apps.github.models.mixins import IssueIndexMixin | ||
|
||
|
||
class PullRequest(BulkSaveModel, IssueIndexMixin, NodeModel, TimestampedModel): |
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.
Every PR is an issue according to GH docs. They have a lot of attributes in common. I think it'd be a good idea to use a base GenericIssueModel
for both entities and extend them as needed.
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.
Ya it's a great Idea!
Let me check on it and inform you!
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.
Also to confirm you want me to make a common model for both Pull request Model and Issues Model? And extend it?
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.
Yes, extract the common fields to GenericIssueModel
abstract model.
Resolves #825
Changes
PullRequest
Model: Introduced a new model to store GitHub pull request data, including fields liketitle
,body
,state
,author
,repository
,created_at
, andmerged_at
.sync_repository
: Integrated PR syncing logic to fetch and update pull requests using GitHub’s API.PullRequest
model to enable management via the Django admin panel.User
,Repository
,Labels
, andAssignees
.This update enables automatic tracking and management of GitHub pull requests within OWASP Nest.