|
1 | 1 | """OWASP Project Health Metrics Node.""" |
2 | 2 |
|
3 | 3 | import strawberry |
| 4 | +import strawberry_django |
4 | 5 |
|
5 | | -from apps.owasp.graphql.nodes.project import ProjectNode |
| 6 | +from apps.owasp.models.project_health_metrics import ProjectHealthMetrics |
6 | 7 |
|
7 | 8 |
|
8 | | -@strawberry.type |
| 9 | +@strawberry_django.type( |
| 10 | + ProjectHealthMetrics, |
| 11 | + fields=[ |
| 12 | + "age_days", |
| 13 | + "contributors_count", |
| 14 | + "forks_count", |
| 15 | + "is_funding_requirements_compliant", |
| 16 | + "is_project_leaders_requirements_compliant", |
| 17 | + "last_commit_days", |
| 18 | + "last_pull_request_days", |
| 19 | + "last_release_days", |
| 20 | + "open_issues_count", |
| 21 | + "owasp_page_last_update_days", |
| 22 | + "recent_releases_count", |
| 23 | + "score", |
| 24 | + "stars_count", |
| 25 | + "unanswered_issues_count", |
| 26 | + "unassigned_issues_count", |
| 27 | + ], |
| 28 | +) |
9 | 29 | class ProjectHealthMetricsNode: |
10 | 30 | """Project health metrics node.""" |
11 | 31 |
|
12 | | - age_days: int = strawberry.field(description="Project age in days") |
13 | | - contributors_count: int = strawberry.field(description="Number of contributors") |
14 | | - last_commit_days: int = strawberry.field(description="Days since last commit") |
15 | | - last_pull_request_days: int = strawberry.field(description="Days since last pull request") |
16 | | - last_release_days: int = strawberry.field(description="Days since last release") |
17 | | - recent_issues_count: int = strawberry.field(description="Recent issues count") |
18 | | - recent_pull_requests_count: int = strawberry.field(description="Recent pull requests count") |
19 | | - recent_releases_count: int = strawberry.field(description="Recent releases count") |
20 | | - score: float = strawberry.field(description="Project health score (0-100)") |
21 | | - forks_count: int = strawberry.field(description="Number of forks") |
22 | | - stars_count: int = strawberry.field(description="Number of stars") |
23 | | - is_project_leaders_requirements_compliant: bool = strawberry.field( |
24 | | - description="Is leaders requirement compliant" |
25 | | - ) |
26 | | - is_funding_requirements_compliant: bool = strawberry.field( |
27 | | - description="Is funding policy requirements compliant" |
28 | | - ) |
29 | | - open_issues_count: int = strawberry.field(description="Open issues count") |
30 | | - unanswered_issues_count: int = strawberry.field(description="Unanswered issues count") |
31 | | - |
32 | 32 | @strawberry.field |
33 | | - def project(self) -> ProjectNode: |
| 33 | + def project_name(self) -> str: |
34 | 34 | """Resolve project node.""" |
35 | | - return self.project |
| 35 | + return self.project.name |
0 commit comments