Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz Source: /opt/alga-psa on psa.joliet.tech
144 lines
4.9 KiB
JavaScript
144 lines
4.9 KiB
JavaScript
function buildPeriodTimestamp(periodStart, dayOffset, hour) {
|
|
const timestamp = new Date(periodStart);
|
|
timestamp.setUTCDate(timestamp.getUTCDate() + dayOffset);
|
|
timestamp.setUTCHours(hour, 39, 14, 459);
|
|
return timestamp;
|
|
}
|
|
|
|
function buildEntryWindow(periodStart, dayOffset, startHour, endHour) {
|
|
const start = buildPeriodTimestamp(periodStart, dayOffset, startHour);
|
|
const end = buildPeriodTimestamp(periodStart, dayOffset, endHour);
|
|
|
|
return {
|
|
start_time: start.toISOString(),
|
|
end_time: end.toISOString(),
|
|
work_date: start.toISOString().slice(0, 10)
|
|
};
|
|
}
|
|
|
|
exports.seed = async function (knex) {
|
|
const tenant = await knex('tenants').select('tenant').first();
|
|
if (!tenant) return;
|
|
|
|
const glinda = await knex('users')
|
|
.where({
|
|
tenant: tenant.tenant,
|
|
username: 'glinda'
|
|
})
|
|
.select('user_id')
|
|
.first();
|
|
|
|
const submittedTimeSheet = await knex('time_sheets as ts')
|
|
.join('time_periods as tp', function joinPeriods() {
|
|
this.on('ts.period_id', '=', 'tp.period_id')
|
|
.andOn('ts.tenant', '=', 'tp.tenant');
|
|
})
|
|
.where({
|
|
'ts.tenant': tenant.tenant,
|
|
'ts.approval_status': 'SUBMITTED'
|
|
})
|
|
.orderBy('tp.start_date', 'desc')
|
|
.select('ts.id', 'tp.start_date', 'tp.end_date')
|
|
.first();
|
|
|
|
const whiteRabbitTicket = await knex('tickets')
|
|
.where({
|
|
tenant: tenant.tenant,
|
|
title: 'Missing White Rabbit'
|
|
})
|
|
.select('ticket_id')
|
|
.first();
|
|
|
|
const emeraldCityTicket = await knex('tickets')
|
|
.where({
|
|
tenant: tenant.tenant,
|
|
title: 'Enhance Emerald City Gardens'
|
|
})
|
|
.select('ticket_id')
|
|
.first();
|
|
|
|
if (!glinda || !submittedTimeSheet || !whiteRabbitTicket || !emeraldCityTicket) return;
|
|
|
|
const dayOne = buildEntryWindow(submittedTimeSheet.start_date, 0, 9, 11);
|
|
const dayTwo = buildEntryWindow(submittedTimeSheet.start_date, 1, 9, 11);
|
|
const dayThree = buildEntryWindow(submittedTimeSheet.start_date, 2, 8, 12);
|
|
const dayFour = buildEntryWindow(submittedTimeSheet.start_date, 3, 9, 11);
|
|
const dayFive = buildEntryWindow(submittedTimeSheet.start_date, 4, 9, 12);
|
|
const secondEntryDayOne = buildEntryWindow(submittedTimeSheet.start_date, 4, 10, 13);
|
|
|
|
return knex('time_entries').insert([
|
|
{
|
|
tenant: tenant.tenant,
|
|
user_id: glinda.user_id,
|
|
...dayOne,
|
|
work_timezone: 'UTC',
|
|
notes: 'Searched for White Rabbit in the Tulgey Wood',
|
|
work_item_id: whiteRabbitTicket.ticket_id,
|
|
billable_duration: 120,
|
|
work_item_type: 'ticket',
|
|
approval_status: 'SUBMITTED',
|
|
time_sheet_id: submittedTimeSheet.id
|
|
},
|
|
{
|
|
tenant: tenant.tenant,
|
|
user_id: glinda.user_id,
|
|
...dayTwo,
|
|
work_timezone: 'UTC',
|
|
notes: 'Moving on to March Hares Residence',
|
|
work_item_id: whiteRabbitTicket.ticket_id,
|
|
billable_duration: 120,
|
|
work_item_type: 'ticket',
|
|
approval_status: 'SUBMITTED',
|
|
time_sheet_id: submittedTimeSheet.id
|
|
},
|
|
{
|
|
tenant: tenant.tenant,
|
|
user_id: glinda.user_id,
|
|
...dayThree,
|
|
work_timezone: 'UTC',
|
|
notes: 'Repaired cracks in the Yellow Brick Road near Munchkinland',
|
|
work_item_id: whiteRabbitTicket.ticket_id,
|
|
billable_duration: 240,
|
|
work_item_type: 'ticket',
|
|
approval_status: 'SUBMITTED',
|
|
time_sheet_id: submittedTimeSheet.id
|
|
},
|
|
{
|
|
tenant: tenant.tenant,
|
|
user_id: glinda.user_id,
|
|
...dayFour,
|
|
work_timezone: 'UTC',
|
|
notes: 'Administrative tasks',
|
|
work_item_id: null,
|
|
billable_duration: 0,
|
|
work_item_type: 'non_billable_category',
|
|
approval_status: 'SUBMITTED',
|
|
time_sheet_id: submittedTimeSheet.id
|
|
},
|
|
{
|
|
tenant: tenant.tenant,
|
|
user_id: glinda.user_id,
|
|
...dayFive,
|
|
work_timezone: 'UTC',
|
|
notes: 'Conducted survey of uncharted areas in Wonderland',
|
|
work_item_id: whiteRabbitTicket.ticket_id,
|
|
billable_duration: 180,
|
|
work_item_type: 'ticket',
|
|
approval_status: 'SUBMITTED',
|
|
time_sheet_id: submittedTimeSheet.id
|
|
},
|
|
{
|
|
tenant: tenant.tenant,
|
|
user_id: glinda.user_id,
|
|
...secondEntryDayOne,
|
|
work_timezone: 'UTC',
|
|
notes: 'Worked on enhancing Emerald City Gardens',
|
|
work_item_id: emeraldCityTicket.ticket_id,
|
|
billable_duration: 180,
|
|
work_item_type: 'ticket',
|
|
approval_status: 'SUBMITTED',
|
|
time_sheet_id: submittedTimeSheet.id
|
|
}
|
|
]);
|
|
};
|