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
46 lines
1.6 KiB
TypeScript
46 lines
1.6 KiB
TypeScript
import type { Knex } from 'knex';
|
|
import { TicketModel } from '../../models/ticketModel';
|
|
|
|
/**
|
|
* A ticket is "untouched" when no human has worked it: no human-authored
|
|
* comments, no time entries, and no manual status change. Status changes are
|
|
* detected by comparing against the tenant's default ticket status — alert
|
|
* tickets are always created in the default status, so any other status means
|
|
* a person (or another automation) moved it. Rule-driven auto-assignment does
|
|
* not count as touched.
|
|
*/
|
|
export async function isTicketUntouched(
|
|
trx: Knex | Knex.Transaction,
|
|
tenantId: string,
|
|
ticketId: string
|
|
): Promise<boolean> {
|
|
const ticket = await trx('tickets')
|
|
.where({ tenant: tenantId, ticket_id: ticketId })
|
|
.first('status_id', 'board_id');
|
|
if (!ticket) return false;
|
|
|
|
// Statuses are board-scoped; compare against the same default the ticket
|
|
// was created with (see ticketCreator.ts).
|
|
const defaultStatusId = await TicketModel.getDefaultStatusId(
|
|
tenantId,
|
|
trx as Knex.Transaction,
|
|
ticket.board_id
|
|
);
|
|
if (defaultStatusId && ticket.status_id !== defaultStatusId) {
|
|
return false;
|
|
}
|
|
|
|
const humanComment = await trx('comments')
|
|
.where({ tenant: tenantId, ticket_id: ticketId })
|
|
.andWhere((qb) => qb.where('is_system_generated', false).orWhereNull('is_system_generated'))
|
|
.first('comment_id');
|
|
if (humanComment) return false;
|
|
|
|
const timeEntry = await trx('time_entries')
|
|
.where({ tenant: tenantId, work_item_id: ticketId, work_item_type: 'ticket' })
|
|
.first('entry_id');
|
|
if (timeEntry) return false;
|
|
|
|
return true;
|
|
}
|