From 3b135f749adc285b8667e3015be343ea8f7e371d Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Tue, 7 Nov 2023 19:22:45 +0700 Subject: [PATCH] UBER-942: Rework skill optimization (#3941) Signed-off-by: Andrey Sobolev --- models/core/src/tx.ts | 3 + models/recruit/src/migration.ts | 22 + models/server-tracker/src/index.ts | 4 +- packages/core/src/operations.ts | 12 +- packages/core/src/tx.ts | 25 +- .../src/components/DocPopup.svelte | 18 +- .../src/components/ObjectPopup.svelte | 4 +- packages/query/src/index.ts | 26 + .../ui/src/components/EditWithIcon.svelte | 39 +- .../ui/src/components/PopupInstance.svelte | 24 +- packages/ui/src/components/SelectPopup.svelte | 15 +- .../src/components/EventPresenter.svelte | 8 +- plugins/calendar-resources/src/index.ts | 3 +- plugins/client-resources/src/connection.ts | 43 +- .../src/components/AssigneePopup.svelte | 31 +- .../src/components/CreateCandidate.svelte | 26 +- .../src/components/OptimizeSkills.svelte | 551 ++++++++++++++++++ .../src/components/SkillsView.svelte | 14 +- .../src/components/CategoryBar.svelte | 32 +- .../src/components/TagItem.svelte | 20 +- .../src/components/TagsView.svelte | 6 +- plugins/tags-resources/src/utils.ts | 8 + .../src/components/StatusSelector.svelte | 16 +- .../components/SetDueDateActionPopup.svelte | 9 +- .../components/issues/AssigneeEditor.svelte | 25 +- plugins/tracker-resources/src/utils.ts | 2 +- .../src/components/ValueSelector.svelte | 37 +- .../src/components/list/ListCategory.svelte | 13 + .../src/components/Workbench.svelte | 2 +- plugins/workbench-resources/src/connect.ts | 13 +- server-plugins/chunter-resources/src/index.ts | 69 ++- .../notification-resources/src/index.ts | 18 +- server-plugins/tracker-resources/src/index.ts | 2 +- server/backup/src/index.ts | 5 +- server/core/src/indexer/indexer.ts | 4 +- server/core/src/storage.ts | 7 +- server/core/src/triggers.ts | 58 +- server/rpc/src/rpc.ts | 1 + server/ws/src/client.ts | 72 ++- server/ws/src/server.ts | 22 +- server/ws/src/types.ts | 1 + 41 files changed, 1063 insertions(+), 247 deletions(-) create mode 100644 plugins/recruit-resources/src/components/OptimizeSkills.svelte diff --git a/models/core/src/tx.ts b/models/core/src/tx.ts index 67cb95d663..218b1b8118 100644 --- a/models/core/src/tx.ts +++ b/models/core/src/tx.ts @@ -101,6 +101,9 @@ export class TTxApplyIf extends TTx implements TxApplyIf { // All matches should be false for all documents. notMatch!: DocumentClassQuery[] txes!: TxCUD[] + + notify!: boolean + extraNotify!: Ref>[] } @Model(core.class.TxWorkspaceEvent, core.class.Doc) diff --git a/models/recruit/src/migration.ts b/models/recruit/src/migration.ts index 20ebfc6eea..8fe9425bfa 100644 --- a/models/recruit/src/migration.ts +++ b/models/recruit/src/migration.ts @@ -55,6 +55,28 @@ export const recruitOperation: MigrateOperation = { } }) } + }, + { + state: 'wrong-categories', + func: async (client): Promise => { + const ops = new TxOperations(client, core.account.System) + while (true) { + const docs = await ops.findAll( + tags.class.TagElement, + { + targetClass: recruit.mixin.Candidate, + category: { $in: [tracker.category.Other, 'document:category:Other' as Ref] } + }, + { limit: 1000 } + ) + for (const d of docs) { + await ops.update(d, { category: recruit.category.Other }) + } + if (docs.length === 0) { + break + } + } + } } ]) } diff --git a/models/server-tracker/src/index.ts b/models/server-tracker/src/index.ts index c4c80b72bc..ce7464fa2c 100644 --- a/models/server-tracker/src/index.ts +++ b/models/server-tracker/src/index.ts @@ -43,8 +43,8 @@ export function createModel (builder: Builder): void { builder.createDoc(serverCore.class.Trigger, core.space.Model, { trigger: serverTracker.trigger.OnComponentRemove, txMatch: { - _class: core.class.TxCollectionCUD, - 'tx._class': core.class.TxCreateDoc + _class: core.class.TxRemoveDoc, + objectClass: tracker.class.Component } }) diff --git a/packages/core/src/operations.ts b/packages/core/src/operations.ts index 56fbc4223f..1f4a33ca66 100644 --- a/packages/core/src/operations.ts +++ b/packages/core/src/operations.ts @@ -441,10 +441,18 @@ export class ApplyOperations extends TxOperations { return this } - async commit (): Promise { + async commit (notify: boolean = true, extraNotify: Ref>[] = []): Promise { if (this.txes.length > 0) { return await ((await this.ops.tx( - this.ops.txFactory.createTxApplyIf(core.space.Tx, this.scope, this.matches, this.notMatches, this.txes) + this.ops.txFactory.createTxApplyIf( + core.space.Tx, + this.scope, + this.matches, + this.notMatches, + this.txes, + notify, + extraNotify + ) )) as Promise) } return true diff --git a/packages/core/src/tx.ts b/packages/core/src/tx.ts index 540bcfb00f..9905fce3f8 100644 --- a/packages/core/src/tx.ts +++ b/packages/core/src/tx.ts @@ -51,16 +51,17 @@ export enum WorkspaceEvent { Upgrade, IndexingUpdate, SecurityChange, - MaintenanceNotification + MaintenanceNotification, + BulkUpdate } /** * Event to be send by server during model upgrade procedure. * @public */ -export interface TxWorkspaceEvent extends Tx { +export interface TxWorkspaceEvent extends Tx { event: WorkspaceEvent - params: any + params: T } /** @@ -70,6 +71,13 @@ export interface IndexingUpdateEvent { _class: Ref>[] } +/** + * @public + */ +export interface BulkUpdateEvent { + _class: Ref>[] +} + /** * @public */ @@ -125,6 +133,11 @@ export interface TxApplyIf extends Tx { // If all matched execute following transactions. txes: TxCUD[] + + notify?: boolean // If false will not send notifications. + + // If passed, will send WorkspaceEvent.BulkUpdate event with list of classes to update + extraNotify?: Ref>[] } /** @@ -591,6 +604,8 @@ export class TxFactory { match: DocumentClassQuery[], notMatch: DocumentClassQuery[], txes: TxCUD[], + notify: boolean = true, + extraNotify: Ref>[] = [], modifiedOn?: Timestamp, modifiedBy?: Ref ): TxApplyIf { @@ -604,7 +619,9 @@ export class TxFactory { scope, match, notMatch, - txes + txes, + notify, + extraNotify } } } diff --git a/packages/presentation/src/components/DocPopup.svelte b/packages/presentation/src/components/DocPopup.svelte index f97926fcd5..312bf8f1f1 100644 --- a/packages/presentation/src/components/DocPopup.svelte +++ b/packages/presentation/src/components/DocPopup.svelte @@ -24,6 +24,7 @@ IconCheck, IconSearch, ListView, + Spinner, createFocusManager, deviceOptionsStore, resizeObserver, @@ -59,6 +60,7 @@ export let disallowDeselect: Ref[] | undefined = undefined export let created: Doc[] = [] export let embedded: boolean = false + export let loading = false let search: string = '' @@ -185,7 +187,7 @@ icon={IconAdd} showTooltip={{ label: create.label }} on:click={onCreate} - disabled={readonly} + disabled={readonly || loading} /> {/if} @@ -210,20 +212,24 @@ {@const isDeselectDisabled = selectedElements.has(obj._id) && forbiddenDeselectItemIds.has(obj._id)}