-
-
Notifications
You must be signed in to change notification settings - Fork 270
Improve dashboard metrics list #1967
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
Changes from 2 commits
2b0e912
d73b3a8
cc9b6a4
848244e
9ce072f
6d7d47a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| """OWASP Project Health Metrics Ordering.""" | ||
|
|
||
| from strawberry import auto | ||
| import strawberry | ||
| from strawberry_django import order_type | ||
|
|
||
| from apps.owasp.models.project_health_metrics import ProjectHealthMetrics | ||
|
|
@@ -10,4 +10,9 @@ | |
| class ProjectHealthMetricsOrder: | ||
| """Ordering for Project Health Metrics.""" | ||
|
|
||
| score: auto | ||
| score: strawberry.auto | ||
| # We need to order by another field in case of equal scores | ||
| # to ensure unique metrics in pagination. | ||
| # because SQL returns random order if no order is specified. | ||
| # We didn't do this ordering in the model since we order already in the query. | ||
| project__name: strawberry.auto | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason for having
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. strawberry use these attributes in the |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,7 +52,9 @@ const MetricsPage: FC = () => { | |
| }, | ||
| } | ||
|
|
||
| let currentFilters = {} | ||
| let currentFilters = { | ||
| isActive: true, | ||
| } | ||
| let currentOrdering = { | ||
| score: 'DESC', | ||
| } | ||
|
|
@@ -62,6 +64,7 @@ const MetricsPage: FC = () => { | |
| const currentFilterKeys = [] | ||
| if (healthFilter) { | ||
| currentFilters = { | ||
| ...currentFilters, | ||
| ...healthFiltersMapping[healthFilter], | ||
| } | ||
| currentFilterKeys.push(healthFilter) | ||
|
|
@@ -99,7 +102,12 @@ const MetricsPage: FC = () => { | |
| variables: { | ||
| filters, | ||
| pagination: { offset: 0, limit: PAGINATION_LIMIT }, | ||
| ordering, | ||
| ordering: [ | ||
| ordering, | ||
| { | ||
| ['project_Name']: 'ASC', | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What naming convention was used here?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is automatically converted by strawberry. Since the attribute is
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure how it works though. Let's merge it as is and improve sorting capabilities later. |
||
| }, | ||
| ], | ||
| }, | ||
| }) | ||
|
|
||
|
|
@@ -176,7 +184,7 @@ const MetricsPage: FC = () => { | |
| } else { | ||
| newParams.delete('health') | ||
| newParams.delete('level') | ||
| newFilters = {} | ||
| newFilters = { isActive: true } | ||
| } | ||
| setFilters(newFilters) | ||
| setActiveFilters( | ||
|
|
@@ -246,7 +254,12 @@ const MetricsPage: FC = () => { | |
| variables: { | ||
| filters, | ||
| pagination: newPagination, | ||
| ordering, | ||
| ordering: [ | ||
| ordering, | ||
| { | ||
| ['project_Name']: 'ASC', | ||
| }, | ||
| ], | ||
| }, | ||
| updateQuery: (prev, { fetchMoreResult }) => { | ||
| if (!fetchMoreResult) return prev | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.