Skip to content

Commit 808542f

Browse files
committed
fix(quality-dashboard): scorecard display and sorting
1 parent 6a17e3f commit 808542f

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

testgen/ui/components/frontend/js/pages/quality_dashboard.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,23 @@ const QualityDashboard = (/** @type {Properties} */ props) => {
3838

3939
const sortedBy = van.state('name');
4040
const filterTerm = van.state('');
41+
42+
const scoreToNumber = (score) => score ? (score.startsWith('>') ? 99.99 : Number(score)) : 101;
43+
const sortFunctions = {
44+
name: (a, b) => caseInsensitiveSort(a.name, b.name),
45+
score: (a, b) => {
46+
const scoreA = Math.min(scoreToNumber(a.score), scoreToNumber(a.cde_score));
47+
const scoreB = Math.min(scoreToNumber(b.score), scoreToNumber(b.cde_score));
48+
return scoreA - scoreB;
49+
},
50+
};
51+
4152
const scores = van.derive(() => {
4253
const sort = getValue(sortedBy) ?? 'name';
4354
const filter = getValue(filterTerm) ?? '';
4455
return getValue(props.scores)
4556
.filter(score => caseInsensitiveIncludes(score.name, filter))
46-
.sort((a, b) => caseInsensitiveSort(a[sort], b[sort]));
57+
.sort(sortFunctions[sort]);
4758
});
4859

4960
return div(

testgen/ui/queries/scoring_queries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
@st.cache_data(show_spinner="Loading data :gray[:small[(This might take a few minutes)]] ...")
1010
def get_all_score_cards(project_code: str) -> list["ScoreCard"]:
1111
results = [
12-
definition.as_cached_score_card()
12+
definition.as_cached_score_card(include_definition=True)
1313
for definition in ScoreDefinition.all(project_code=project_code, last_history_items=50)
1414
]
1515
return results

testgen/ui/views/score_details.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def render(
8080
issues = None
8181
with st.spinner(text="Loading data :gray[:small[(This might take a few minutes)]] ..."):
8282
user_can_edit = session.auth.user_has_permission("edit")
83-
score_card = format_score_card(score_definition.as_cached_score_card())
83+
score_card = format_score_card(score_definition.as_cached_score_card(include_definition=True))
8484
if score_type not in typing.get_args(ScoreTypes):
8585
score_type = None
8686
if not score_type:

0 commit comments

Comments
 (0)