From a518af86c47afbbf57c7c23ea7aa4882e2e32e0e Mon Sep 17 00:00:00 2001 From: jfrer Date: Tue, 2 Jul 2024 17:29:24 +0200 Subject: [PATCH] Revert "feat: add sorting by label, metric (wip), year" This reverts commit b6dd235e267c6f46489afd334356ba0098c211b5. --- .../workflows/WorkflowsTimeline.vue | 18 ++---- .../workflows/timeline/TimelineSorting.vue | 55 ---------------- src/helpers/sorting.ts | 64 ------------------- src/locales/de.json | 8 +-- src/locales/en.json | 8 +-- src/types/index.d.ts | 10 ++- 6 files changed, 11 insertions(+), 152 deletions(-) delete mode 100644 src/components/workflows/timeline/TimelineSorting.vue delete mode 100644 src/helpers/sorting.ts diff --git a/src/components/workflows/WorkflowsTimeline.vue b/src/components/workflows/WorkflowsTimeline.vue index cd31198..c3c4d63 100644 --- a/src/components/workflows/WorkflowsTimeline.vue +++ b/src/components/workflows/WorkflowsTimeline.vue @@ -1,7 +1,7 @@ - \ No newline at end of file diff --git a/src/helpers/sorting.ts b/src/helpers/sorting.ts deleted file mode 100644 index 04037af..0000000 --- a/src/helpers/sorting.ts +++ /dev/null @@ -1,64 +0,0 @@ -import workflowsStore from "@/store/workflows-store" -import type { EvaluationResultsDocumentWide, EvaluationRun, GroundTruth, TimeSpan } from "@/types" - -const GTTimelineSortingOptions = { - LABEL_ASC: 'label_asc', - LABEL_DESC: 'label_desc', - METRIC_DESC: 'metric_desc', - METRIC_ASC: 'metric_asc', - YEAR_ASC: 'year_asc', - YEAR_DESC: 'year_desc' -} - -function sortByOption(gtList: GroundTruth[], sortingOption: string, metric: keyof EvaluationResultsDocumentWide): GroundTruth[] { - if (sortingOption === GTTimelineSortingOptions.METRIC_DESC) return sortByMetric(gtList, true, metric) - if (sortingOption === GTTimelineSortingOptions.METRIC_ASC) return sortByMetric(gtList, false, metric) - if (sortingOption === GTTimelineSortingOptions.LABEL_DESC) return sortByLabel(gtList, true) - if (sortingOption === GTTimelineSortingOptions.LABEL_ASC) return sortByLabel(gtList, false) - if (sortingOption === GTTimelineSortingOptions.YEAR_DESC) return sortByYear(gtList, true) - if (sortingOption === GTTimelineSortingOptions.YEAR_ASC) return sortByYear(gtList, false) - return gtList -} - -function sortByMetric(gtList: GroundTruth[], desc: boolean, metric: keyof EvaluationResultsDocumentWide): GroundTruth[] { - return gtList.sort((left, right) => { - const compareMetric = (left: GroundTruth, right: GroundTruth) => { - const leftRuns = workflowsStore.getRuns(left.id) //assume getLatestRuns(id) TODO -> change to latestRuns - const rightRuns = workflowsStore.getRuns(right.id) //same here - - const getAverageValue = (runs: EvaluationRun[]) => { - if (runs.length === 0) return 0 - return runs.reduce((acc, curr) => { - const value = curr.evaluation_results.document_wide[metric] - return acc += value ?? 0 - }, 0) / runs.length - } - - return getAverageValue(leftRuns) - getAverageValue(rightRuns) - } - return desc ? compareMetric(right, left) : compareMetric(left, right) - }) -} - -function sortByLabel(gtList: GroundTruth[], desc: boolean): GroundTruth[] { - return gtList.sort((left, right) => { - const leftLabel = left.label.toLocaleLowerCase() - const rightLabel = right.label.toLocaleLowerCase() - return desc ? rightLabel.localeCompare(leftLabel) : leftLabel.localeCompare(rightLabel) - }) -} - -function sortByYear(gtList: GroundTruth[], desc: boolean): GroundTruth[] { - return gtList.sort((left, right) => { - const compareTimeSpan = (leftTime: TimeSpan, rightTime: TimeSpan) => { - return (leftTime.notBefore > rightTime.notBefore) ? 1 : ((rightTime.notBefore > leftTime.notBefore) ? -1 : 0) - } - return desc ? compareTimeSpan(right.metadata.time, left.metadata.time) : compareTimeSpan(left.metadata.time, right.metadata.time) - }) -} - - - -export { - GTTimelineSortingOptions, sortByOption -} \ No newline at end of file diff --git a/src/locales/de.json b/src/locales/de.json index 46abdec..db55ba1 100644 --- a/src/locales/de.json +++ b/src/locales/de.json @@ -86,11 +86,5 @@ "filter_by_processor": "Nach Prozessor filtern", "select_a_date_range": "Zeitraum auswählen", "select_a_workflow": "Workflow auswählen", - "select_a_processor": "Prozessor auswählen", - "label_asc": "Titel (a - z)", - "label_desc": "Titel (z - a)", - "metric_desc": "Ausgewählte Metrik (absteigend)", - "metric_asc": "Ausgewählte Metrik (aufsteigend)", - "year_asc": "Zeitraum (ältester - neuster)", - "year_desc": "Zeitraum (neuster - ältester)" + "select_a_processor": "Prozessor auswählen" } diff --git a/src/locales/en.json b/src/locales/en.json index 95866bb..2fc3f36 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -80,11 +80,5 @@ "filter_by_processor": "Filter by processor", "select_a_date_range": "Select a date range", "select_a_workflow": "Select a workflow", - "select_a_processor": "Select a processor", - "label_asc": "Label (a - z)", - "label_desc": "Label (z - a)", - "metric_desc": "Selected metric (descending)", - "metric_asc": "Selected metric (ascending)", - "year_asc": "Time period (oldest - latest)", - "year_desc": "Time period (latest - oldest)" + "select_a_processor": "Select a processor" } diff --git a/src/types/index.d.ts b/src/types/index.d.ts index f7bc246..2776794 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -32,7 +32,10 @@ export interface GroundTruthMetadata { reference: string, link: string }[], - time: TimeSpan + time: { + notBefore: string, + notAfter: string + }, title: string, 'transcription-guidelines': string, url: string, @@ -51,11 +54,6 @@ export interface GroundTruthMetadata { }[], } -export interface TimeSpan { - notBefore: string, - notAfter: string -} - export interface Workflow { id: string, label: string,