Skip to content

Commit

Permalink
Fixed calculation of in-progress units
Browse files Browse the repository at this point in the history
  • Loading branch information
meta-paul committed Aug 15, 2024
1 parent 1f53b84 commit 4dc823f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
22 changes: 16 additions & 6 deletions mephisto/review_app/client/src/pages/TaskStatsPage/Histogram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -61,9 +69,9 @@ export function Histogram(props: HistogramPropsType) {
<g key={i}>
<rect
x={xScale(0)}
y={yScale(truncatedLabel)}
width={xScale(d.value)}
height={yScale.bandwidth()}
y={y}
width={xScale(d.value) || ZERO_LINE_WIDTH_PX}
height={LINE_HEIGHT_PX}
opacity={1}
stroke="#cbedec"
fill="#cbedec"
Expand All @@ -73,7 +81,8 @@ export function Histogram(props: HistogramPropsType) {
/>
<text
x={xScale(d.value) + 8}
y={y + yScale.bandwidth() / 2}
y={y + LINE_HEIGHT_PX / 2}
height={LINE_HEIGHT_PX}
textAnchor="start"
alignmentBaseline="central"
fontSize={12}
Expand All @@ -84,7 +93,8 @@ export function Histogram(props: HistogramPropsType) {
<text
className={"label"}
x={xScale(0) - 8}
y={y + yScale.bandwidth() / 2}
y={y + LINE_HEIGHT_PX / 2}
height={LINE_HEIGHT_PX}
textAnchor="end"
alignmentBaseline="central"
fontSize={12}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
}

.task-stats .content .stats .field-stats .histogram-name {
font-size: 32px;
font-size: 24px;
padding-left: 20px;
padding-bottom: 20px;
}
Expand Down
2 changes: 1 addition & 1 deletion mephisto/review_app/server/api/views/tasks_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def get(self) -> 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"])
Expand Down
2 changes: 1 addition & 1 deletion mephisto/utils/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 4dc823f

Please sign in to comment.