Skip to content

Commit

Permalink
Sort branches such that higher numbers are first (more recent branches)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaXal committed Nov 14, 2023
1 parent 81dfaea commit f66ccf2
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 19 deletions.
117 changes: 117 additions & 0 deletions dashboard/app/tests/branchConfigurator.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import { expect, test } from "vitest"
import { sortBranches } from "new-dashboard/src/configurators/BranchConfigurator"

test("sort branches", () => {
const branches = [
"abubenchikov/maven-cache-interpolation",
"abubenchikov/maven-only-root-poms",
"akoehler/233_additional_logging_for_IDEA-242343",
"akoehler/with_akuznezov_6271d740e94a",
"alexey.kryuchkov/checkout-with-disabled-mapping",
"master",
"semantic-search-perf-impact-with-actions",
"alexey.kryuchkov/investigate-storing-time",
"alexey.kryuchkov/spans-with-the-samename-test",
"yaroshchuk/IJI-1297-perf-tests",
"yartamonov/crazy-visitors",
"alexey.kryuchkov/trying-to-reset-all-branches-bycommit-hash",
"cheremin/fast-file-attributes-over-mmapped-file",
"dz/vcs-log-loading-details-separate-statistics-current-scope",
"cheremin/IJPL-193-enable-new-filepagecache",
"cheremin/vfs-enable-fast-names-enumerator",
"cheremin/vfs-refactoring",
"db/in-memory-indexes",
"dz/git-branches-popup-building-tree-span",
"231",
"232",
"233",
"dz/vcs-log-loading-details-end-span-before-process-wait",
"dz/vcs-log-loading-details-separate-statistics",
"alexey.kryuchkov/investigate-multiple-scheduling",
"dz/vcs-log-loading-details-without-processing-tests",
"gliullin/fix-class-names-in-perfomance-tests",
"gliullin/VS-1490/VS-1490/do-not-perform-synchronous-refresh-under-read-lock",
"gliullin/VS-1591/do-not-perform-synchronous-refresh-under-read-lock",
"gregsh/actions",
"lena/indexingStampRevertExperiment",
"lena/indexingTestIndexingStampInvestigation",
"maxim.kolmakov/1s-recent-files",
"maxim.kolmakov/500-lines-intellij-preloading",
"maxim.kolmakov/5000-lines-and-5-seconds",
"maxim.kolmakov/5000-lines-limit",
"maxim.kolmakov/disable-OT",
"msokolov/idea-314818-3",
"msokolov/idea-314818-4",
"msokolov/idea-314818-5",
"nikita.barkov/16_09_maven_degradation_after",
"nikita.barkov/maven_degradation_investigation_before",
"nikita.barkov/maven_degradation_with_suspect",
"nikita.barkov/maven_import_before_fixed_flag",
"plate/caches",
"plate/changelog",
"plate/disabledCaches",
"plate/squashHarder",
"shagvaliev/package-checker-refactor",
"vadim.salavatov/IJPL-52-optimization-baseline",
"vadim.salavatov/IJPL-52-optimization-baseline-low",
"vadim.salavatov/IJPL-52-optimize-no-workers",
"wsm/sdk_wip",
"semantic-search-perf-impact-with-all-together",
].sort(sortBranches)
expect(branches).toStrictEqual([
"master",
"233",
"232",
"231",
"abubenchikov/maven-cache-interpolation",
"abubenchikov/maven-only-root-poms",
"akoehler/233_additional_logging_for_IDEA-242343",
"akoehler/with_akuznezov_6271d740e94a",
"alexey.kryuchkov/checkout-with-disabled-mapping",
"alexey.kryuchkov/investigate-multiple-scheduling",
"alexey.kryuchkov/investigate-storing-time",
"alexey.kryuchkov/spans-with-the-samename-test",
"alexey.kryuchkov/trying-to-reset-all-branches-bycommit-hash",
"cheremin/fast-file-attributes-over-mmapped-file",
"cheremin/IJPL-193-enable-new-filepagecache",
"cheremin/vfs-enable-fast-names-enumerator",
"cheremin/vfs-refactoring",
"db/in-memory-indexes",
"dz/git-branches-popup-building-tree-span",
"dz/vcs-log-loading-details-end-span-before-process-wait",
"dz/vcs-log-loading-details-separate-statistics",
"dz/vcs-log-loading-details-separate-statistics-current-scope",
"dz/vcs-log-loading-details-without-processing-tests",
"gliullin/fix-class-names-in-perfomance-tests",
"gliullin/VS-1490/VS-1490/do-not-perform-synchronous-refresh-under-read-lock",
"gliullin/VS-1591/do-not-perform-synchronous-refresh-under-read-lock",
"gregsh/actions",
"lena/indexingStampRevertExperiment",
"lena/indexingTestIndexingStampInvestigation",
"maxim.kolmakov/1s-recent-files",
"maxim.kolmakov/500-lines-intellij-preloading",
"maxim.kolmakov/5000-lines-and-5-seconds",
"maxim.kolmakov/5000-lines-limit",
"maxim.kolmakov/disable-OT",
"msokolov/idea-314818-3",
"msokolov/idea-314818-4",
"msokolov/idea-314818-5",
"nikita.barkov/16_09_maven_degradation_after",
"nikita.barkov/maven_degradation_investigation_before",
"nikita.barkov/maven_degradation_with_suspect",
"nikita.barkov/maven_import_before_fixed_flag",
"plate/caches",
"plate/changelog",
"plate/disabledCaches",
"plate/squashHarder",
"shagvaliev/package-checker-refactor",
"vadim.salavatov/IJPL-52-optimization-baseline",
"vadim.salavatov/IJPL-52-optimization-baseline-low",
"vadim.salavatov/IJPL-52-optimize-no-workers",
"wsm/sdk_wip",
"yaroshchuk/IJI-1297-perf-tests",
"yartamonov/crazy-visitors",
"semantic-search-perf-impact-with-actions",
"semantic-search-perf-impact-with-all-together",
])
})
22 changes: 3 additions & 19 deletions dashboard/new-dashboard/src/components/common/BranchSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
<script setup lang="ts">
import { ChevronDownIcon } from "@heroicons/vue/20/solid"
import { computed, ref } from "vue"
import { sortBranches } from "../../configurators/BranchConfigurator"
import { DimensionConfigurator } from "../../configurators/DimensionConfigurator"
import { branchesSelectLabelFormat } from "../../shared/labels"
import { usePlaceholder } from "../charts/placeholder"
Expand Down Expand Up @@ -181,29 +182,12 @@ function createItems(configurator?: DimensionConfigurator) {
if (configurator == undefined) {
return []
}
console.log(configurator.values.value)
const values = (configurator.values.value as string[]).sort((a, b) => {
if (configurator.selected.value?.includes(b)) return 1
if (configurator.selected.value?.includes(a)) return -1
if (a === "master") return -1
if (b === "master") return 1
// Then numbers
const isANumber = !Number.isNaN(Number(a))
const isBNumber = !Number.isNaN(Number(b))
if (isANumber && !isBNumber) return -1
if (!isANumber && isBNumber) return 1
// Then strings that contain "/"
const hasASlash = a.includes("/")
const hasBSlash = b.includes("/")
if (hasASlash && !hasBSlash) return -1
if (!hasASlash && hasBSlash) return 1
// Then everything else
return a.localeCompare(b)
return sortBranches(a, b)
})
return values.map((it) => {
Expand Down
23 changes: 23 additions & 0 deletions dashboard/new-dashboard/src/configurators/BranchConfigurator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,26 @@ export function createBranchConfigurator(
})
return configurator
}

export function sortBranches(a: string, b: string): number {
if (a === "master") return -1
if (b === "master") return 1

// Then numbers
const isANumber = !Number.isNaN(Number(a))
const isBNumber = !Number.isNaN(Number(b))

if (isANumber && !isBNumber) return -1
if (!isANumber && isBNumber) return 1
if (isANumber && isBNumber) return Number(b) - Number(a)

// Then strings that contain "/"
const hasASlash = a.includes("/")
const hasBSlash = b.includes("/")

if (hasASlash && !hasBSlash) return -1
if (!hasASlash && hasBSlash) return 1

// Then everything else
return a.localeCompare(b)
}

0 comments on commit f66ccf2

Please sign in to comment.