-
-
Notifications
You must be signed in to change notification settings - Fork 522
Implement Milestones #1406
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
Merged
arkid15r
merged 74 commits into
OWASP:main
from
ahmedxgouda:feature/implement-milestones
May 17, 2025
Merged
Implement Milestones #1406
Changes from all commits
Commits
Show all changes
74 commits
Select commit
Hold shift + click to select a range
e9e2288
Add Milestone model and OpenMilestoneManager
ahmedxgouda bf32c6b
Add MilestoneNode and MilestoneQuery for GitHub milestones
ahmedxgouda 84d3f19
Fix docstrings
ahmedxgouda cfb9773
Merge branch 'main' into feature/implement-milestones
ahmedxgouda fbf7375
Add Milestone model migration and update model imports
ahmedxgouda 9968bfa
Merge branch 'main' into feature/implement-milestones
ahmedxgouda efa926e
Fix spelling
ahmedxgouda 31ae544
Merge branch 'main' into feature/implement-milestones
ahmedxgouda 817bdea
Merge migrations
ahmedxgouda b8c3df0
Add milestone field to Issue and PullRequest models
ahmedxgouda 79b7ac1
Sync milestone data
ahmedxgouda ee26c79
sync milestone labels
ahmedxgouda ad94c0f
Add property to retrieve the latest updated milestone in the Reposito…
ahmedxgouda 15b2b26
Refactor import order in milestone queries and include MilestoneQuery…
ahmedxgouda c33499b
Update milestone author retrieval in sync_repository function
ahmedxgouda 5114b35
Fix milestone author retrieval in sync_repository function
ahmedxgouda e5e6f40
Enhance MilestoneNode and MilestoneQuery with project and repository …
ahmedxgouda 2d0bbcb
Implement the project milestone queries
ahmedxgouda 1dff560
Merge branch 'main' into feature/implement-milestones
ahmedxgouda bad79f3
Add open and closed milestones properties to Repository model and upd…
ahmedxgouda 07b1bb3
Add open and closed milestones fields to repository and project test …
ahmedxgouda 362757a
Refactor MilestoneNode to remove issues and pull_requests fields, and…
ahmedxgouda 96e1a41
Refactor open and closed milestones properties in Repository model to…
ahmedxgouda 70c2417
Add milestone queries to the frontend
ahmedxgouda c80b77c
Merge branch 'main' into feature/implement-milestones
ahmedxgouda a69f324
Add Milestones component and integrate into Home page; update types a…
ahmedxgouda ae326d2
Enhance Milestones component: add closed and open issues count displa…
ahmedxgouda bfb016c
Refactor Milestone queries and components: remove body field, add url…
ahmedxgouda 8568e73
Add open and closed milestones to Project and Repository details; upd…
ahmedxgouda 8dc942f
Add createdAt field to ProjectMilestonesType interface
ahmedxgouda fe592fa
Apply DRY to milestones queries
ahmedxgouda 917b9e2
Implement/Update unit tests for milestones.
ahmedxgouda 3c22b57
Fix formatting
ahmedxgouda 967dc92
Fix unit tests
ahmedxgouda 95efc02
Implement e2e tests
ahmedxgouda b1103b1
Fix e2e milestone tests
ahmedxgouda 50710a5
Merge branch 'main' into feature/implement-milestones
ahmedxgouda e39f13a
Add test cases for MilestoneNode class
ahmedxgouda 787e45d
Rename test for closed milestones to improve clarity
ahmedxgouda 9444bf8
Fix e2e bug.
ahmedxgouda 2a94607
Merge branch 'main' into feature/implement-milestones
ahmedxgouda b37bdbf
Refactor Milestones component to remove unnecessary href prop from An…
ahmedxgouda caf03e2
Refactor for the checks
ahmedxgouda 4955e05
Merge branch 'main' into feature/implement-milestones
ahmedxgouda 217232a
Merge branch 'main' into feature/implement-milestones
ahmedxgouda 0a701ce
Fix formatting in update_data method and remove unnecessary blank lin…
ahmedxgouda b37a964
Merge branch 'main' into feature/implement-milestones
ahmedxgouda a8a414f
Merge branch 'main' into feature/implement-milestones
ahmedxgouda bd3f08d
Refactor MilestoneQuery to support filtering by milestone state and u…
ahmedxgouda 57761ec
Fix milestone query parameters to use state instead of close flag
ahmedxgouda f71b8a9
Refactor from_github method signatures in Issue and PullRequest model…
ahmedxgouda 5adf568
Merge branch 'main' into feature/implement-milestones
ahmedxgouda 6007d77
Merge migrations
ahmedxgouda 46f1f82
Merge branch 'main' into feature/implement-milestones
ahmedxgouda b759bae
Update GitHub app admin
kasya 5d7845d
Add make-check changes
kasya c95bad1
Merge branch 'main' into feature/implement-milestones
kasya 7c8092e
Merge branch 'main' into feature/implement-milestones
ahmedxgouda 225df60
Refactor milestone handling in Repository and Project nodes to use re…
ahmedxgouda 7572bc3
Update frontend
ahmedxgouda 559b979
Update frontend tests
ahmedxgouda 395e6b6
Update backend tests
ahmedxgouda ec58681
Merge branch 'main' into feature/implement-milestones
ahmedxgouda 6320859
Update code
arkid15r cbd41e0
Update code
arkid15r 644fa0b
Merge branch 'main' into feature/implement-milestones
ahmedxgouda 2af9463
Add distinct and remove unused filters
ahmedxgouda 8decfda
Revert previous remove for filtering milestones and change the query …
ahmedxgouda a8caef7
Add milestones to organization page and tests
ahmedxgouda 069b0ec
Add milestones to user
ahmedxgouda 255b2bc
Add recent milestones to user details tests and mock data
ahmedxgouda 9889cf1
Add more tests
ahmedxgouda e9c983a
Merge branch 'main' into feature/implement-milestones
ahmedxgouda f692a06
Update code
arkid15r File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| """Github Milestone Node.""" | ||
|
|
||
| import graphene | ||
|
|
||
| from apps.common.graphql.nodes import BaseNode | ||
| from apps.github.models.milestone import Milestone | ||
|
|
||
|
|
||
| class MilestoneNode(BaseNode): | ||
| """Github Milestone Node.""" | ||
|
|
||
| organization_name = graphene.String() | ||
| repository_name = graphene.String() | ||
|
|
||
| class Meta: | ||
| model = Milestone | ||
|
|
||
| fields = ( | ||
| "author", | ||
| "created_at", | ||
| "title", | ||
| "open_issues_count", | ||
| "closed_issues_count", | ||
| "url", | ||
| ) | ||
|
|
||
| def resolve_repository_name(self, info): | ||
| """Resolve repository name.""" | ||
| return self.repository.name | ||
|
|
||
| def resolve_organization_name(self, info): | ||
| """Return organization name.""" | ||
| return self.repository.organization.login if self.repository.organization else None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| """Github Milestone Queries.""" | ||
|
|
||
| import graphene | ||
| from django.core.exceptions import ValidationError | ||
| from django.db.models import OuterRef, Subquery | ||
|
|
||
| from apps.common.graphql.queries import BaseQuery | ||
| from apps.github.graphql.nodes.milestone import MilestoneNode | ||
| from apps.github.models.milestone import Milestone | ||
|
|
||
|
|
||
| class MilestoneQuery(BaseQuery): | ||
| """Github Milestone Queries.""" | ||
|
|
||
| recent_milestones = graphene.List( | ||
| MilestoneNode, | ||
| distinct=graphene.Boolean(default_value=False), | ||
| limit=graphene.Int(default_value=5), | ||
| login=graphene.String(required=False), | ||
| organization=graphene.String(required=False), | ||
| state=graphene.String(default_value="open"), | ||
| ) | ||
|
|
||
| def resolve_recent_milestones( | ||
| root, | ||
| info, | ||
| *, | ||
| distinct: bool = False, | ||
| limit: int = 5, | ||
| login: str | None = None, | ||
| organization: str | None = None, | ||
| state: str = "open", | ||
| ): | ||
| """Resolve milestones. | ||
|
|
||
| Args: | ||
| root (object): The root object. | ||
| info (ResolveInfo): The GraphQL execution context. | ||
| distinct (bool): Whether to return distinct milestones. | ||
| limit (int): The maximum number of milestones to return. | ||
| login (str, optional): The GitHub username to filter milestones. | ||
| organization (str, optional): The GitHub organization to filter milestones. | ||
| state (str, optional): The state of the milestones to return. | ||
|
|
||
| Returns: | ||
| list: A list of milestones. | ||
|
|
||
| """ | ||
| match state.lower(): | ||
| case "open": | ||
| milestones = Milestone.open_milestones.all() | ||
| case "closed": | ||
| milestones = Milestone.closed_milestones.all() | ||
| case "all": | ||
| milestones = Milestone.objects.all() | ||
| case _: | ||
| message = f"Invalid state: {state}. Valid states are 'open', 'closed', or 'all'." | ||
| raise ValidationError(message) | ||
|
|
||
| milestones = milestones.select_related( | ||
| "author", | ||
| "repository", | ||
| "repository__organization", | ||
| ).prefetch_related( | ||
| "issues", | ||
| "labels", | ||
| "pull_requests", | ||
| ) | ||
| if login: | ||
| milestones = milestones.filter( | ||
| author__login=login, | ||
| ) | ||
|
|
||
| if organization: | ||
| milestones = milestones.filter( | ||
| repository__organization__login=organization, | ||
| ) | ||
|
|
||
| if distinct: | ||
ahmedxgouda marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| latest_milestone_per_author = ( | ||
| milestones.filter(author_id=OuterRef("author_id")) | ||
| .order_by("-created_at") | ||
| .values("id")[:1] | ||
| ) | ||
| milestones = milestones.filter( | ||
| id__in=Subquery(latest_milestone_per_author), | ||
| ).order_by( | ||
| "-created_at", | ||
| ) | ||
|
|
||
| return milestones[:limit] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| # Generated by Django 5.2 on 2025-04-21 14:45 | ||
|
|
||
| import django.db.models.deletion | ||
| from django.db import migrations, models | ||
|
|
||
| import apps.github.models.mixins.issue | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| dependencies = [ | ||
| ("github", "0023_alter_user_contributions_count"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.CreateModel( | ||
| name="Milestone", | ||
| fields=[ | ||
| ( | ||
| "id", | ||
| models.BigAutoField( | ||
| auto_created=True, primary_key=True, serialize=False, verbose_name="ID" | ||
| ), | ||
| ), | ||
| ("nest_created_at", models.DateTimeField(auto_now_add=True)), | ||
| ("nest_updated_at", models.DateTimeField(auto_now=True)), | ||
| ("node_id", models.CharField(unique=True, verbose_name="Node ID")), | ||
| ("title", models.CharField(max_length=1000, verbose_name="Title")), | ||
| ("body", models.TextField(default="", verbose_name="Body")), | ||
| ( | ||
| "state", | ||
| models.CharField( | ||
| choices=[("open", "Open"), ("closed", "Closed")], | ||
| default="open", | ||
| max_length=6, | ||
| verbose_name="State", | ||
| ), | ||
| ), | ||
| ("url", models.URLField(default="", max_length=500, verbose_name="URL")), | ||
| ("number", models.PositiveBigIntegerField(default=0, verbose_name="Number")), | ||
| ("sequence_id", models.PositiveBigIntegerField(default=0, verbose_name="ID")), | ||
| ( | ||
| "closed_at", | ||
| models.DateTimeField(blank=True, null=True, verbose_name="Closed at"), | ||
| ), | ||
| ("created_at", models.DateTimeField(verbose_name="Created at")), | ||
| ("updated_at", models.DateTimeField(db_index=True, verbose_name="Updated at")), | ||
| ("open_issues_count", models.PositiveIntegerField(default=0)), | ||
| ("closed_issues_count", models.PositiveIntegerField(default=0)), | ||
| ("due_on", models.DateTimeField(blank=True, null=True)), | ||
| ( | ||
| "author", | ||
| models.ForeignKey( | ||
| blank=True, | ||
| null=True, | ||
| on_delete=django.db.models.deletion.CASCADE, | ||
| related_name="milestones", | ||
| to="github.user", | ||
| ), | ||
| ), | ||
| ( | ||
| "labels", | ||
| models.ManyToManyField( | ||
| blank=True, related_name="milestones", to="github.label" | ||
| ), | ||
| ), | ||
| ( | ||
| "repository", | ||
| models.ForeignKey( | ||
| blank=True, | ||
| null=True, | ||
| on_delete=django.db.models.deletion.CASCADE, | ||
| related_name="milestones", | ||
| to="github.repository", | ||
| ), | ||
| ), | ||
| ], | ||
| options={ | ||
| "verbose_name_plural": "Milestones", | ||
| "db_table": "github_milestone", | ||
| "ordering": ["-updated_at", "-state"], | ||
| }, | ||
| bases=(apps.github.models.mixins.issue.IssueIndexMixin, models.Model), | ||
| ), | ||
| ] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.