mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-13 11:50:56 +00:00
parent
f5682c1f73
commit
ab4cea6ee6
@ -144,8 +144,20 @@ export async function createClient (
|
||||
|
||||
const txMap = new Map<Ref<Tx>, Ref<Tx>>()
|
||||
for (const tx of txes) txMap.set(tx._id, tx._id)
|
||||
for (const tx of txes) hierarchy.tx(tx)
|
||||
for (const tx of txes) await model.tx(tx)
|
||||
for (const tx of txes) {
|
||||
try {
|
||||
hierarchy.tx(tx)
|
||||
} catch (err: any) {
|
||||
console.error('failed to apply model transaction, skipping', JSON.stringify(tx), err)
|
||||
}
|
||||
}
|
||||
for (const tx of txes) {
|
||||
try {
|
||||
await model.tx(tx)
|
||||
} catch (err: any) {
|
||||
console.error('failed to apply model transaction, skipping', JSON.stringify(tx), err)
|
||||
}
|
||||
}
|
||||
|
||||
txBuffer = txBuffer.filter((tx) => txMap.get(tx._id) === undefined)
|
||||
|
||||
|
@ -364,7 +364,7 @@ export class Hierarchy {
|
||||
const _cl = getClass(v as ToClassRefT<T, keyof T>)
|
||||
if (this.isMixin(_cl)) {
|
||||
const mval = (lookup as any)[k]
|
||||
if (mval !== undefined) {
|
||||
if (mval != null) {
|
||||
(lookup as any)[k] = this.as(mval, _cl)
|
||||
}
|
||||
}
|
||||
|
@ -30,34 +30,45 @@
|
||||
}
|
||||
|
||||
let search: string = ''
|
||||
let vquery: string = ''
|
||||
let resultQuery: DocumentQuery<Doc> = {}
|
||||
let vacancyQuery: DocumentQuery<Doc> = {}
|
||||
|
||||
async function updateResultQuery (search: string): Promise<void> {
|
||||
resultQuery = search === '' ? {} : { $search: search }
|
||||
}
|
||||
|
||||
let vacancies: Vacancy[] = []
|
||||
const query = createQuery()
|
||||
let appQuery = false
|
||||
|
||||
$: query.query(recruit.class.Vacancy, { archived: false }, (res) => {
|
||||
vacancies = res
|
||||
})
|
||||
|
||||
$: if (vacancies.length > 0) {
|
||||
function lowerIncludes (a?: string, b: string): boolean {
|
||||
return (a ?? '').toLowerCase().includes(b)
|
||||
}
|
||||
|
||||
$: if (vacancies.length > 0 && !appQuery) {
|
||||
vacancyQuery = {
|
||||
_id: {
|
||||
$in: vacancies
|
||||
.filter((it) => it.name.includes(search) || it.description.includes(search) || it.company?.includes(search) || ((applications?.get(it._id) ?? 0) > 0))
|
||||
.filter(
|
||||
(it) =>
|
||||
lowerIncludes(it.name, vquery) ||
|
||||
lowerIncludes(it.description, vquery) ||
|
||||
lowerIncludes(it.company, vquery) ||
|
||||
(applications?.get(it._id) ?? 0) > 0
|
||||
)
|
||||
.map((it) => it._id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$: resultQuery = vquery === '' ? {} : { $search: vquery }
|
||||
|
||||
let applications: Map<Ref<Vacancy>, number> | undefined
|
||||
|
||||
const applicantQuery = createQuery()
|
||||
$: if (vacancies.length > 0) {
|
||||
appQuery = true
|
||||
applicantQuery.query(
|
||||
recruit.class.Applicant,
|
||||
{ ...(resultQuery as DocumentQuery<Applicant>), space: { $in: vacancies.map((it) => it._id) } },
|
||||
@ -69,6 +80,7 @@
|
||||
}
|
||||
|
||||
applications = result
|
||||
appQuery = false
|
||||
}
|
||||
)
|
||||
}
|
||||
@ -86,7 +98,7 @@
|
||||
<SearchEdit
|
||||
bind:value={search}
|
||||
on:change={() => {
|
||||
updateResultQuery(search)
|
||||
vquery = search
|
||||
}}
|
||||
/>
|
||||
<Button label={recruit.string.Create} primary={true} size={'small'} on:click={(ev) => showCreateDialog(ev)} />
|
||||
|
@ -314,12 +314,20 @@ export async function createServerStorage (conf: DbConfiguration, options?: Serv
|
||||
const model = await txAdapter.getModel()
|
||||
|
||||
for (const tx of model) {
|
||||
hierarchy.tx(tx)
|
||||
await triggers.tx(tx)
|
||||
try {
|
||||
hierarchy.tx(tx)
|
||||
await triggers.tx(tx)
|
||||
} catch (err: any) {
|
||||
console.error('failed to apply model transaction, skipping', JSON.stringify(tx), err)
|
||||
}
|
||||
}
|
||||
|
||||
for (const tx of model) {
|
||||
await modelDb.tx(tx)
|
||||
try {
|
||||
await modelDb.tx(tx)
|
||||
} catch (err: any) {
|
||||
console.error('failed to apply model transaction, skipping', JSON.stringify(tx), err)
|
||||
}
|
||||
}
|
||||
|
||||
for (const [, adapter] of adapters) {
|
||||
|
Loading…
Reference in New Issue
Block a user