mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-11 04:07:43 +02:00
+24
-11
@@ -1,5 +1,5 @@
|
||||
|
||||
import { Ref, TxOperations } from '@anticrm/core'
|
||||
import { genRanks, Ref, TxOperations } from '@anticrm/core'
|
||||
import task, { DoneState, Kanban, SpaceWithStates, State } from '@anticrm/task'
|
||||
import { findOrUpdate } from './utils'
|
||||
|
||||
@@ -12,42 +12,55 @@ export async function createUpdateSpaceKanban (spaceId: Ref<SpaceWithStates>, cl
|
||||
{ color: '#F28469', name: 'Invalid' }
|
||||
]
|
||||
const states: Array<Ref<State>> = []
|
||||
const stateRanks = genRanks(rawStates.length)
|
||||
for (const st of rawStates) {
|
||||
const rank = stateRanks.next().value
|
||||
|
||||
if (rank === undefined) {
|
||||
console.error('Failed to generate rank')
|
||||
break
|
||||
}
|
||||
|
||||
const sid = ('generated-' + spaceId + '.state.' + st.name.toLowerCase().replace(' ', '_')) as Ref<State>
|
||||
await findOrUpdate(client, spaceId, task.class.State,
|
||||
sid,
|
||||
{
|
||||
title: st.name,
|
||||
color: st.color
|
||||
color: st.color,
|
||||
rank
|
||||
}
|
||||
)
|
||||
states.push(sid)
|
||||
}
|
||||
|
||||
const rawDoneStates = [
|
||||
const doneStates = [
|
||||
{ class: task.class.WonState, title: 'Won' },
|
||||
{ class: task.class.LostState, title: 'Lost' }
|
||||
]
|
||||
const doneStates: Array<Ref<DoneState>> = []
|
||||
for (const st of rawDoneStates) {
|
||||
const doneStateRanks = genRanks(doneStates.length)
|
||||
for (const st of doneStates) {
|
||||
const rank = doneStateRanks.next().value
|
||||
|
||||
if (rank === undefined) {
|
||||
console.error('Failed to generate rank')
|
||||
break
|
||||
}
|
||||
|
||||
const sid = ('generated-' + spaceId + '.done-state.' + st.title.toLowerCase().replace(' ', '_')) as Ref<DoneState>
|
||||
await findOrUpdate(client, spaceId, st.class,
|
||||
sid,
|
||||
{
|
||||
title: st.title
|
||||
title: st.title,
|
||||
rank
|
||||
}
|
||||
)
|
||||
doneStates.push(sid)
|
||||
}
|
||||
|
||||
await findOrUpdate(client, spaceId,
|
||||
task.class.Kanban,
|
||||
('generated-' + spaceId + '.kanban') as Ref<Kanban>,
|
||||
{
|
||||
attachedTo: spaceId,
|
||||
states,
|
||||
doneStates,
|
||||
order: []
|
||||
attachedTo: spaceId
|
||||
}
|
||||
)
|
||||
return states
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import contact from '@anticrm/contact'
|
||||
import core, { AttachedData, Data, generateId, Ref, TxOperations } from '@anticrm/core'
|
||||
import core, { AttachedData, Data, generateId, genRanks, Ref, TxOperations } from '@anticrm/core'
|
||||
import recruit from '@anticrm/model-recruit'
|
||||
import { Applicant, Candidate, Vacancy } from '@anticrm/recruit'
|
||||
import faker from 'faker'
|
||||
@@ -79,7 +79,7 @@ export async function generateContacts (transactorUrl: string, dbName: string, o
|
||||
}
|
||||
const vacancyId = (options.random ? `vacancy-${generateId()}-${i}` : `vacancy-genid-${i}`) as Ref<Vacancy>
|
||||
|
||||
console.log('Creating vacandy', vacancy.name)
|
||||
console.log('Creating vacancy', vacancy.name)
|
||||
// Update or create candidate
|
||||
await findOrUpdate(client, core.space.Model, recruit.class.Vacancy, vacancyId, vacancy)
|
||||
|
||||
@@ -93,14 +93,22 @@ export async function generateContacts (transactorUrl: string, dbName: string, o
|
||||
|
||||
console.log('States generated', vacancy.name)
|
||||
|
||||
const rankGen = genRanks(candidates.length)
|
||||
for (const candidateId of candidates) {
|
||||
const rank = rankGen.next().value
|
||||
|
||||
if (rank === undefined) {
|
||||
throw Error('Failed to generate rank')
|
||||
}
|
||||
|
||||
const applicantId = `vacancy-${vacancyId}-${candidateId}` as Ref<Applicant>
|
||||
|
||||
const applicant: AttachedData<Applicant> = {
|
||||
number: faker.datatype.number(),
|
||||
assignee: faker.random.arrayElement(emoloyeeIds),
|
||||
state: faker.random.arrayElement(states),
|
||||
doneState: null
|
||||
doneState: null,
|
||||
rank
|
||||
}
|
||||
|
||||
// Update or create candidate
|
||||
|
||||
Reference in New Issue
Block a user