Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
CarsonF committed Dec 17, 2024
2 parents 7661b35 + 72c7acc commit 6a9aca2
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 12 deletions.
17 changes: 15 additions & 2 deletions src/components/pnp/extraction-result/extraction-result.dto.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Field, InterfaceType, ObjectType } from '@nestjs/graphql';
import { Field, InputType, InterfaceType, ObjectType } from '@nestjs/graphql';
import { many, Many } from '@seedcompany/common';
import { stripIndent } from 'common-tags';
import { UUID } from 'node:crypto';
import { keys as keysOf } from 'ts-transformer-keys';
import { Merge } from 'type-fest';
import * as uuid from 'uuid';
import { EnumType, ID, IdField, makeEnum } from '~/common';
import { EnumType, ID, IdField, makeEnum, SecuredProps } from '~/common';
import { InlineMarkdownScalar } from '~/common/markdown.scalar';
import { Cell } from '~/common/xlsx.util';

Expand Down Expand Up @@ -118,8 +119,20 @@ export type StoredProblem = Pick<PnpProblem, 'id'> & {
context: { [x: string]: unknown };
};

@InputType()
export class PnpExtractionResultFilters {
@Field(() => Boolean, {
nullable: true,
description: 'Only extraction results containing errors',
})
readonly hasError?: boolean;
}

@InterfaceType()
export abstract class PnpExtractionResult {
static readonly Props = keysOf<PnpExtractionResult>();
static readonly SecuredProps = keysOf<SecuredProps<PnpExtractionResult>>();

constructor(private readonly fileVersionId: ID<'FileVersion'>) {}

readonly problems = new Map<ID, StoredProblem>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,22 @@ import { inArray, node, relation } from 'cypher-query-builder';
import { SetNonNullable } from 'type-fest';
import { ID, PublicOf } from '~/common';
import { CommonRepository } from '~/core/database';
import { apoc, collect, exp, merge, variable } from '~/core/database/query';
import {
apoc,
collect,
count,
defineSorters,
exp,
filter,
merge,
SortCol,
variable,
} from '~/core/database/query';
import {
PnpExtractionResult,
PnpExtractionResultFilters,
PnpProblemType,
PnpProblemSeverity as Severity,
StoredProblem,
} from './extraction-result.dto';
import { PnpExtractionResultRepository } from './pnp-extraction-result.edgedb.repository';
Expand Down Expand Up @@ -117,3 +129,25 @@ export class PnpExtractionResultNeo4jRepository
.run();
}
}

export const pnpExtractionResultFilters = filter.define(
() => PnpExtractionResultFilters,
{
hasError: filter.pathExists([
node('node'),
relation('out', '', 'problem'),
node('', { severity: Severity.Error }),
]),
},
);

export const pnpExtractionResultSorters = defineSorters(PnpExtractionResult, {
totalErrors: (query) =>
query
.match([
node('node'),
relation('out', 'problem', 'problem'),
node('type', { severity: Severity.Error }),
])
.return<SortCol>(count('problem').as('sortValue')),
});
12 changes: 4 additions & 8 deletions src/components/pnp/verifyEngagementDateRangeMatches.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { stripIndent } from 'common-tags';
import { DateTime } from 'luxon';
import { DateInterval } from '~/common';
import {
PnpPlanningExtractionResult,
Expand All @@ -19,10 +20,7 @@ export function verifyEngagementDateRangeMatches(
}

const matches =
engagementRange &&
pnpRange &&
// PnP only specifies months; allow nuance on our side.
engagementRange.expandToFull('month').equals(pnpRange);
engagementRange && pnpRange && engagementRange.equals(pnpRange);

if (matches) {
return true;
Expand Down Expand Up @@ -68,13 +66,11 @@ const MismatchedEngagementDateRange = PnpProblemType.register({
message: stripIndent`
The PnP's **project dates** (\`${source}\`) are different from what is declared in the CORD Engagement/Project.
CORD: ${eng.toLocaleString({ month: 'long', year: 'numeric' })}
PnP: ${pnp.toLocaleString({ month: 'long', year: 'numeric' })}
CORD: ${eng.toLocaleString(DateTime.DATE_MED)}
PnP: ${pnp.toLocaleString(DateTime.DATE_MED)}
Please adjust the dates in CORD or the PnP to match and be accurate.
CORD only requires the month & year to match the PnP since this is as granular as it gets.
If this is a cluster project and this engagement ("language") has started late or ends early,
that difference can be declared in CORD's _Engagement dates_.
`.replaceAll(/\n/g, ' \n'), // keep line breaks with MD's two space trailers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from '~/common';
import { EngagementFilters } from '../../engagement/dto';
import { PeriodicReportListInput } from '../../periodic-report/dto';
import { PnpExtractionResultFilters } from '../../pnp/extraction-result';
import { ProgressSummaryFilters } from '../../progress-summary/dto';
import { ProgressReportStatus } from './progress-report-status.enum';
import { ProgressReport } from './progress-report.entity';
Expand All @@ -27,6 +28,9 @@ export abstract class ProgressReportFilters extends PickType(

@FilterField(() => EngagementFilters)
readonly engagement?: EngagementFilters & {};

@FilterField(() => PnpExtractionResultFilters)
readonly pnpExtractionResult?: PnpExtractionResultFilters & {};
}

@InputType()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { FileVersion } from '../../file/dto';
import { PeriodicReportUploadedEvent } from '../../periodic-report/events';
import { ProgressReport } from '../dto';

@Migration('2024-12-16T16:33:00')
@Migration('2024-12-17T16:00:00')
export class ReextractPnpProgressReportsMigration extends BaseMigration {
constructor(
private readonly eventBus: IEventBus,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
} from '~/core/database/query';
import { engagementSorters } from '../engagement/engagement.repository';
import { MergePeriodicReports } from '../periodic-report/dto';
import { pnpExtractionResultSorters } from '../pnp/extraction-result/pnp-extraction-result.neo4j.repository';
import { SummaryPeriod } from '../progress-summary/dto';
import { progressSummarySorters } from '../progress-summary/progress-summary.repository';
import { ProgressReport, ProgressReportStatus as Status } from './dto';
Expand Down Expand Up @@ -50,6 +51,18 @@ export const progressReportExtrasSorters: DefinedSorters<
SortFieldOf<typeof ProgressReport>
> = defineSorters(ProgressReport, {
// eslint-disable-next-line @typescript-eslint/naming-convention
'pnpExtractionResult.*': (query, input) =>
query
.with('node as report')
.match([
node('report'),
relation('out', '', 'reportFileNode'),
node('file', 'File'),
relation('out', '', 'pnpExtractionResult'),
node('node', 'PnpExtractionResult'),
])
.apply(sortWith(pnpExtractionResultSorters, input)),
// eslint-disable-next-line @typescript-eslint/naming-convention
'engagement.*': (query, input) =>
query
.with('node as report')
Expand Down
10 changes: 10 additions & 0 deletions src/components/progress-report/progress-report.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
} from '~/core/database/query';
import { engagementFilters } from '../engagement/engagement.repository';
import { progressReportSorters } from '../periodic-report/periodic-report.repository';
import { pnpExtractionResultFilters } from '../pnp/extraction-result/pnp-extraction-result.neo4j.repository';
import { SummaryPeriod } from '../progress-summary/dto';
import { progressSummaryFilters } from '../progress-summary/progress-summary.repository';
import {
Expand Down Expand Up @@ -109,5 +110,14 @@ export const progressReportFilters = filter.define(
node('node', 'Engagement'),
]),
),
pnpExtractionResult: filter.sub(() => pnpExtractionResultFilters)((sub) =>
sub.match([
node('outer'),
relation('out', '', 'reportFileNode'),
node('file', 'File'),
relation('out', '', 'pnpExtractionResult'),
node('node', 'PnpExtractionResult'),
]),
),
},
);

0 comments on commit 6a9aca2

Please sign in to comment.