From 4dc823f2a77546c877c2c3b9e7a340838257769e Mon Sep 17 00:00:00 2001 From: Paul Abumov Date: Thu, 15 Aug 2024 14:02:41 -0400 Subject: [PATCH] Fixed calculation of in-progress units --- .../src/pages/TaskStatsPage/Histogram.tsx | 22 ++++++++++++++----- .../src/pages/TaskStatsPage/TaskStatsPage.css | 2 +- .../review_app/server/api/views/tasks_view.py | 2 +- mephisto/utils/metrics.py | 2 +- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/mephisto/review_app/client/src/pages/TaskStatsPage/Histogram.tsx b/mephisto/review_app/client/src/pages/TaskStatsPage/Histogram.tsx index 08e7d3dac..204cd16cb 100644 --- a/mephisto/review_app/client/src/pages/TaskStatsPage/Histogram.tsx +++ b/mephisto/review_app/client/src/pages/TaskStatsPage/Histogram.tsx @@ -8,6 +8,14 @@ const BAR_PADDING = 0.2; const TRUNCATE_LABEL_LENGTH = 20; +// Somehow it's 3px if value `1` and the minimum is still 2px even if value less than `1`. +// Changing `strokeWidth` does not help +const ZERO_LINE_WIDTH_PX = 0.1; + +const LINE_HEIGHT_PX = 20; + +const VERTICAL_GAP_BETWEEN_LINES_PX = 4; + function truncateLabel(text: string, n: number): string { return text.length > n ? text.slice(0, n - 1) + "..." : text; } @@ -52,7 +60,7 @@ export function Histogram(props: HistogramPropsType) { const allShapes = data.map((d: HistogramData, i: number) => { const truncatedLabel = truncateLabel(d.label, TRUNCATE_LABEL_LENGTH); - const y = yScale(truncatedLabel); + const y = i * (LINE_HEIGHT_PX + VERTICAL_GAP_BETWEEN_LINES_PX); if (y === undefined) { return null; } @@ -61,9 +69,9 @@ export function Histogram(props: HistogramPropsType) { dict: unit_all_count = len(db_units) unit_completed_count = len(find_completed_units(int(t["task_id"]))) unit_finished_count = len( - [u["status"] in AssignmentState.final_agent() for u in db_units] + [u for u in db_units if u["status"] in AssignmentState.final_agent()] ) is_reviewed = check_if_task_reviewed(task_id=t["task_id"]) has_stats = _check_task_has_stats(task_id=t["task_id"]) diff --git a/mephisto/utils/metrics.py b/mephisto/utils/metrics.py index a8dab0f0e..3062a68bd 100644 --- a/mephisto/utils/metrics.py +++ b/mephisto/utils/metrics.py @@ -272,7 +272,7 @@ def get_default_dashboard_url() -> str: """ headers_dict = {"Accept": "application/json"} grafana_url = get_grafana_url() - url = urljoin(grafana_url, "/api/search?query=Default%20Mephisto%20Monitorin") + url = urljoin(grafana_url, "/api/search?query=Default%20Mephisto%20Monitoring") r = requests.get( url,