ezqms-1213: gets rid of tosorted (#6775)

Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com>
This commit is contained in:
Alexey Zinoviev 2024-10-01 16:19:07 +04:00 committed by GitHub
parent 48c840f631
commit 473e57d328
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 34 additions and 20 deletions

View File

@ -52,7 +52,7 @@
(doc.major === $controlledDocument.major && doc.minor <= $controlledDocument.minor) (doc.major === $controlledDocument.major && doc.minor <= $controlledDocument.minor)
) )
}) })
.toSorted(documentCompareFn) .sort(documentCompareFn)
function getDescription (cc: ChangeControl | undefined): string { function getDescription (cc: ChangeControl | undefined): string {
if (cc === undefined) { if (cc === undefined) {

View File

@ -7,6 +7,7 @@
"build": "compile ui", "build": "compile ui",
"build:watch": "compile ui", "build:watch": "compile ui",
"format": "format src", "format": "format src",
"svelte-check": "do-svelte-check",
"_phase:build": "compile ui", "_phase:build": "compile ui",
"_phase:format": "format src", "_phase:format": "format src",
"_phase:validate": "compile validate" "_phase:validate": "compile validate"

View File

@ -45,12 +45,12 @@
$: if (showDiff && assessmentData !== null) { $: if (showDiff && assessmentData !== null) {
indices = assessmentData.correctOrder indices = assessmentData.correctOrder
.map((position, index) => [position, index]) .map((position, index) => [position, index])
.toSorted(([aPosition], [bPosition]) => (aPosition > bPosition ? 1 : aPosition < bPosition ? -1 : 0)) .sort(([aPosition], [bPosition]) => (aPosition > bPosition ? 1 : aPosition < bPosition ? -1 : 0))
.map(([_, index]) => index) as [number, ...number[]] .map(([_, index]) => index) as [number, ...number[]]
} else if (answerData !== null) { } else if (answerData !== null) {
indices = answerData.order indices = answerData.order
.map((position, index) => [position, index]) .map((position, index) => [position, index])
.toSorted(([aPosition], [bPosition]) => (aPosition > bPosition ? 1 : aPosition < bPosition ? -1 : 0)) .sort(([aPosition], [bPosition]) => (aPosition > bPosition ? 1 : aPosition < bPosition ? -1 : 0))
.map(([_, index]) => index) as [number, ...number[]] .map(([_, index]) => index) as [number, ...number[]]
} else { } else {
indices = questionData.options.map((_, index) => index) as [number, ...number[]] indices = questionData.options.map((_, index) => index) as [number, ...number[]]
@ -67,7 +67,7 @@
indices = moveItem(indices, from, to) indices = moveItem(indices, from, to)
const order = indices const order = indices
.map((initialIndex, index) => [initialIndex, index]) .map((initialIndex, index) => [initialIndex, index])
.toSorted(([aInitialIndex], [bInitialIndex]) => .sort(([aInitialIndex], [bInitialIndex]) =>
aInitialIndex > bInitialIndex ? 1 : aInitialIndex < bInitialIndex ? -1 : 0 aInitialIndex > bInitialIndex ? 1 : aInitialIndex < bInitialIndex ? -1 : 0
) )
.map(([_, index]) => index + 1) as [OrderingPosition, ...OrderingPosition[]] .map(([_, index]) => index + 1) as [OrderingPosition, ...OrderingPosition[]]

View File

@ -16,6 +16,8 @@ MultipleChoiceAssessmentAnswer
return { return {
score: score:
// eslint-disable-next-line @typescript-eslint/require-array-sort-compare // eslint-disable-next-line @typescript-eslint/require-array-sort-compare
answerData.selectedIndices.toSorted().join('~') === assessmentData.correctIndices.toSorted().join('~') ? 100 : 0 answerData.selectedIndices.slice().sort().join('~') === assessmentData.correctIndices.slice().sort().join('~')
? 100
: 0
} }
} }

View File

@ -15,7 +15,7 @@
--> -->
<script lang="ts"> <script lang="ts">
import { AttachmentStyleBoxCollabEditor } from '@hcengineering/attachment-resources' import { AttachmentStyleBoxCollabEditor } from '@hcengineering/attachment-resources'
import core, { ClassifierKind, Data, Doc, Mixin, Ref } from '@hcengineering/core' import core, { ClassifierKind, type CollaborativeDoc, Data, Doc, Mixin, Ref } from '@hcengineering/core'
import notification from '@hcengineering/notification' import notification from '@hcengineering/notification'
import { Panel } from '@hcengineering/panel' import { Panel } from '@hcengineering/panel'
import { getResource } from '@hcengineering/platform' import { getResource } from '@hcengineering/platform'
@ -35,7 +35,7 @@
let object: Required<Vacancy> let object: Required<Vacancy>
let rawName: string = '' let rawName: string = ''
let rawDesc: string = '' let rawDesc: string = ''
let rawFullDesc: string = '' let rawFullDesc: CollaborativeDoc
let lastId: Ref<Vacancy> | undefined = undefined let lastId: Ref<Vacancy> | undefined = undefined
let showAllMixins = false let showAllMixins = false

View File

@ -26,10 +26,14 @@
let candidate: Candidate | undefined = undefined let candidate: Candidate | undefined = undefined
const client = getClient() const client = getClient()
const hierarchy = client.getHierarchy() const hierarchy = client.getHierarchy()
$: spaceQuery.query(recruit.class.Vacancy, { _id: value.space }, (res) => ([currentVacancy] = res)) $: spaceQuery.query(recruit.class.Vacancy, { _id: value.space }, (res) => {
;[currentVacancy] = res
})
const shortLabel = value && hierarchy.getClass(value._class).shortLabel const shortLabel = value && hierarchy.getClass(value._class).shortLabel
$: candidateQuery.query(recruit.mixin.Candidate, { _id: value.attachedTo }, (res) => ([candidate] = res)) $: candidateQuery.query(recruit.mixin.Candidate, { _id: value.attachedTo }, (res) => {
;[candidate] = res
})
$: title = `${shortLabel}-${value?.number}` $: title = `${shortLabel}-${value?.number}`
</script> </script>

View File

@ -232,7 +232,8 @@
goodTagMap = toIdMap(goodTags) goodTagMap = toIdMap(goodTags)
const goodSortedTags = goodTags const goodSortedTags = goodTags
.toSorted((a, b) => b.title.length - a.title.length) .slice()
.sort((a, b) => b.title.length - a.title.length)
.filter((t) => t.title.length > 2) .filter((t) => t.title.length > 2)
const goodSortedTagsTitles = new Map<Ref<TagElement>, string>() const goodSortedTagsTitles = new Map<Ref<TagElement>, string>()
processed = -1 processed = -1
@ -251,7 +252,7 @@
const tagElementIds = new Map<Ref<TagElement>, TagUpdatePlan['elements'][0]>() const tagElementIds = new Map<Ref<TagElement>, TagUpdatePlan['elements'][0]>()
for (const tag of tagElements.toSorted((a, b) => prepareTitle(a.title).length - prepareTitle(b.title).length)) { for (const tag of tagElements.slice().sort((a, b) => prepareTitle(a.title).length - prepareTitle(b.title).length)) {
processed++ processed++
const refs = allRefs.filter((it) => it.tag === tag._id) const refs = allRefs.filter((it) => it.tag === tag._id)
if (goodTagMap.has(tag._id)) { if (goodTagMap.has(tag._id)) {

View File

@ -14,7 +14,9 @@
// limitations under the License. // limitations under the License.
--> -->
<script lang="ts"> <script lang="ts">
export let size: 'x-small' | 'small' | 'medium' | 'large' import { IconSize } from '@hcengineering/ui'
export let size: IconSize
const fill: string = 'currentColor' const fill: string = 'currentColor'
</script> </script>

View File

@ -143,14 +143,14 @@
...gitem.events, ...gitem.events,
...gitem.busyEvents, ...gitem.busyEvents,
...gitem.busy.slots ...gitem.busy.slots
].toSorted((a, b) => a.date - b.date)} ].sort((a, b) => a.date - b.date)}
<div style:overflow-x={'hidden'} style:overflow-y={'auto'} style:height="{height}rem"> <div style:overflow-x={'hidden'} style:overflow-y={'auto'} style:height="{height}rem">
<div class="flex flex-row-center"> <div class="flex flex-row-center">
<div class="flex-nowrap p-1 w-full" style:display={'inline-flex'}> <div class="flex-nowrap p-1 w-full" style:display={'inline-flex'}>
{#each Array.from(Array(24).keys()) as hour} {#each Array.from(Array(24).keys()) as hour}
{@const _slots = slots {@const _slots = slots
.filter((it) => new Date(it.date).getHours() === hour) .filter((it) => new Date(it.date).getHours() === hour)
.toSorted((a, b) => a.date - b.date)} .sort((a, b) => a.date - b.date)}
{@const cwidth = hourWidths[hour]} {@const cwidth = hourWidths[hour]}
<div class="flex-col" style:width="{cwidth}rem"> <div class="flex-col" style:width="{cwidth}rem">
{#each _slots as m, i} {#each _slots as m, i}

View File

@ -7,6 +7,7 @@
"build": "compile ui", "build": "compile ui",
"build:watch": "compile ui", "build:watch": "compile ui",
"format": "format src", "format": "format src",
"svelte-check": "do-svelte-check",
"_phase:build": "compile ui", "_phase:build": "compile ui",
"_phase:format": "format src", "_phase:format": "format src",
"_phase:validate": "compile validate" "_phase:validate": "compile validate"

View File

@ -43,7 +43,7 @@
_id: employee._id as Ref<Item>, _id: employee._id as Ref<Item>,
completion: completionMap.get(employee._id) as CompletionMapValue completion: completionMap.get(employee._id) as CompletionMapValue
})) }))
.toSorted((item1, item2) => compareCompletionMapValueState(item1.completion.state, item2.completion.state)) .sort((item1, item2) => compareCompletionMapValueState(item1.completion.state, item2.completion.state))
}, },
{ {
sort: { sort: {

View File

@ -9,7 +9,7 @@ export async function trainingAttemptStateSort (
_: TxOperations, _: TxOperations,
states: TrainingAttemptState[] states: TrainingAttemptState[]
): Promise<TrainingAttemptState[]> { ): Promise<TrainingAttemptState[]> {
return states.toSorted( return states
(state1, state2) => trainingAttemptStateOrder.indexOf(state2) - trainingAttemptStateOrder.indexOf(state1) .slice()
) .sort((state1, state2) => trainingAttemptStateOrder.indexOf(state2) - trainingAttemptStateOrder.indexOf(state1))
} }

View File

@ -17,5 +17,7 @@ import type { TxOperations } from '@hcengineering/core'
import { type TrainingState, trainingStateOrder } from '@hcengineering/training' import { type TrainingState, trainingStateOrder } from '@hcengineering/training'
export async function trainingStateSort (_: TxOperations, states: TrainingState[]): Promise<TrainingState[]> { export async function trainingStateSort (_: TxOperations, states: TrainingState[]): Promise<TrainingState[]> {
return states.toSorted((state1, state2) => trainingStateOrder.indexOf(state1) - trainingStateOrder.indexOf(state2)) return states
.slice()
.sort((state1, state2) => trainingStateOrder.indexOf(state1) - trainingStateOrder.indexOf(state2))
} }

View File

@ -8,6 +8,7 @@
"build": "compile ui", "build": "compile ui",
"build:docs": "api-extractor run --local", "build:docs": "api-extractor run --local",
"format": "format src", "format": "format src",
"svelte-check": "do-svelte-check",
"build:watch": "compile ui", "build:watch": "compile ui",
"_phase:build": "compile ui", "_phase:build": "compile ui",
"_phase:format": "format src", "_phase:format": "format src",

View File

@ -98,7 +98,7 @@
{/each} {/each}
{#each Object.entries(metrics.params) as [k, v], i} {#each Object.entries(metrics.params) as [k, v], i}
<div style:margin-left={`${level * 0.5}rem`}> <div style:margin-left={`${level * 0.5}rem`}>
{#each Object.entries(v).toSorted((a, b) => b[1].value / (b[1].operations + 1) - a[1].value / (a[1].operations + 1)) as [kk, vv]} {#each Object.entries(v).sort((a, b) => b[1].value / (b[1].operations + 1) - a[1].value / (a[1].operations + 1)) as [kk, vv]}
{@const childExpandable = {@const childExpandable =
vv.topResult !== undefined && vv.topResult !== undefined &&
vv.topResult.length > 0 && vv.topResult.length > 0 &&