Skip to content

Commit

Permalink
ezqms-1213: gets rid of tosorted (#6775)
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com>
  • Loading branch information
lexiv0re authored Oct 1, 2024
1 parent 48c840f commit 473e57d
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
(doc.major === $controlledDocument.major && doc.minor <= $controlledDocument.minor)
)
})
.toSorted(documentCompareFn)
.sort(documentCompareFn)
function getDescription (cc: ChangeControl | undefined): string {
if (cc === undefined) {
Expand Down
1 change: 1 addition & 0 deletions plugins/questions-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"build": "compile ui",
"build:watch": "compile ui",
"format": "format src",
"svelte-check": "do-svelte-check",
"_phase:build": "compile ui",
"_phase:format": "format src",
"_phase:validate": "compile validate"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@
$: if (showDiff && assessmentData !== null) {
indices = assessmentData.correctOrder
.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[]]
} else if (answerData !== null) {
indices = answerData.order
.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[]]
} else {
indices = questionData.options.map((_, index) => index) as [number, ...number[]]
Expand All @@ -67,7 +67,7 @@
indices = moveItem(indices, from, to)
const order = indices
.map((initialIndex, index) => [initialIndex, index])
.toSorted(([aInitialIndex], [bInitialIndex]) =>
.sort(([aInitialIndex], [bInitialIndex]) =>
aInitialIndex > bInitialIndex ? 1 : aInitialIndex < bInitialIndex ? -1 : 0
)
.map(([_, index]) => index + 1) as [OrderingPosition, ...OrderingPosition[]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ MultipleChoiceAssessmentAnswer
return {
score:
// 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
}
}
4 changes: 2 additions & 2 deletions plugins/recruit-resources/src/components/EditVacancy.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
-->
<script lang="ts">
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 { Panel } from '@hcengineering/panel'
import { getResource } from '@hcengineering/platform'
Expand All @@ -35,7 +35,7 @@
let object: Required<Vacancy>
let rawName: string = ''
let rawDesc: string = ''
let rawFullDesc: string = ''
let rawFullDesc: CollaborativeDoc
let lastId: Ref<Vacancy> | undefined = undefined
let showAllMixins = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@
let candidate: Candidate | undefined = undefined
const client = getClient()
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
$: 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}`
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@
goodTagMap = toIdMap(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)
const goodSortedTagsTitles = new Map<Ref<TagElement>, string>()
processed = -1
Expand All @@ -251,7 +252,7 @@
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++
const refs = allRefs.filter((it) => it.tag === tag._id)
if (goodTagMap.has(tag._id)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
// limitations under the License.
-->
<script lang="ts">
export let size: 'x-small' | 'small' | 'medium' | 'large'
import { IconSize } from '@hcengineering/ui'
export let size: IconSize
const fill: string = 'currentColor'
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,14 @@
...gitem.events,
...gitem.busyEvents,
...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 class="flex flex-row-center">
<div class="flex-nowrap p-1 w-full" style:display={'inline-flex'}>
{#each Array.from(Array(24).keys()) as hour}
{@const _slots = slots
.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]}
<div class="flex-col" style:width="{cwidth}rem">
{#each _slots as m, i}
Expand Down
1 change: 1 addition & 0 deletions plugins/training-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"build": "compile ui",
"build:watch": "compile ui",
"format": "format src",
"svelte-check": "do-svelte-check",
"_phase:build": "compile ui",
"_phase:format": "format src",
"_phase:validate": "compile validate"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
_id: employee._id as Ref<Item>,
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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function trainingAttemptStateSort (
_: TxOperations,
states: TrainingAttemptState[]
): Promise<TrainingAttemptState[]> {
return states.toSorted(
(state1, state2) => trainingAttemptStateOrder.indexOf(state2) - trainingAttemptStateOrder.indexOf(state1)
)
return states
.slice()
.sort((state1, state2) => trainingAttemptStateOrder.indexOf(state2) - trainingAttemptStateOrder.indexOf(state1))
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ import type { TxOperations } from '@hcengineering/core'
import { type TrainingState, trainingStateOrder } from '@hcengineering/training'

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))
}
1 change: 1 addition & 0 deletions plugins/workbench-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"build": "compile ui",
"build:docs": "api-extractor run --local",
"format": "format src",
"svelte-check": "do-svelte-check",
"build:watch": "compile ui",
"_phase:build": "compile ui",
"_phase:format": "format src",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
{/each}
{#each Object.entries(metrics.params) as [k, v], i}
<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 =
vv.topResult !== undefined &&
vv.topResult.length > 0 &&
Expand Down

0 comments on commit 473e57d

Please sign in to comment.