Skip to content

Commit

Permalink
Added Engagement.milestoneReached (#3338)
Browse files Browse the repository at this point in the history
Co-authored-by: Carson Full <[email protected]>
  • Loading branch information
atGit2021 and CarsonF authored Dec 12, 2024
1 parent 421140f commit 993aa9d
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dbschema/engagement.esdl
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ module default {
historicGoal: str {
annotation deprecated := "Legacy data";
}

milestoneReached: Language::Milestone {
default := Language::Milestone.Unknown;
};

# I want ceremony to be automatically created when engagement is created.
# Using computed & trigger to do this, because properties with default expressions
Expand Down
10 changes: 10 additions & 0 deletions dbschema/language.esdl
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ module default {
constraint expression on (__subject__ >= 0);
}
}

module Language {
scalar type Milestone extending enum<
Unknown,
None,
OldTestament,
NewTestament,
FullBible,
>;
}

module Ethnologue {
type Language extending Project::ContextAware {
Expand Down
11 changes: 11 additions & 0 deletions dbschema/migrations/00010-m1zbd7j.edgeql

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/components/engagement/dto/create-engagement.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { keys as keysOf } from 'ts-transformer-keys';
import { CalendarDate, DateField, ID, IdField } from '~/common';
import { ChangesetIdField } from '../../changeset';
import { CreateDefinedFileVersionInput } from '../../file/dto';
import { LanguageMilestone } from '../../language/dto';
import { ProductMethodology } from '../../product/dto';
import { InternshipEngagement, LanguageEngagement } from './engagement.dto';
import { InternshipPosition } from './intern-position.enum';
Expand Down Expand Up @@ -70,6 +71,9 @@ export abstract class CreateLanguageEngagement extends CreateEngagement {

@Field({ nullable: true })
readonly historicGoal?: string;

@Field(() => LanguageMilestone, { nullable: true })
readonly milestoneReached?: LanguageMilestone;
}

@InputType()
Expand Down
4 changes: 4 additions & 0 deletions src/components/engagement/dto/engagement.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { e } from '~/core/edgedb';
import { LinkTo, RegisterResource } from '~/core/resources';
import { ChangesetAware } from '../../changeset/dto';
import { Commentable } from '../../comments/dto';
import { SecuredLanguageMilestone } from '../../language/dto';
import { Product, SecuredMethodologies } from '../../product/dto';
import {
InternshipProject,
Expand Down Expand Up @@ -189,6 +190,9 @@ export class LanguageEngagement extends Engagement {

@Field()
readonly historicGoal: SecuredStringNullable;

@Field(() => SecuredLanguageMilestone)
readonly milestoneReached: SecuredLanguageMilestone;
}

@RegisterResource({ db: e.InternshipEngagement })
Expand Down
4 changes: 4 additions & 0 deletions src/components/engagement/dto/update-engagement.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from '~/common';
import { ChangesetIdField } from '../../changeset';
import { CreateDefinedFileVersionInput } from '../../file/dto';
import { LanguageMilestone } from '../../language/dto';
import { ProductMethodology } from '../../product/dto';
import { InternshipEngagement, LanguageEngagement } from './engagement.dto';
import { InternshipPosition } from './intern-position.enum';
Expand Down Expand Up @@ -76,6 +77,9 @@ export abstract class UpdateLanguageEngagement extends UpdateEngagement {

@Field({ nullable: true })
readonly historicGoal?: string;

@Field(() => LanguageMilestone, { nullable: true })
readonly milestoneReached?: LanguageMilestone;
}

@InputType()
Expand Down
1 change: 1 addition & 0 deletions src/components/engagement/engagement.edgedb.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const languageExtraHydrate = {
paratextRegistryId: true,
pnp: true,
historicGoal: true,
milestoneReached: true,
} as const;

const internshipExtraHydrate = {
Expand Down
2 changes: 2 additions & 0 deletions src/components/engagement/engagement.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import * as handlers from './handlers';
import { InternshipEngagementResolver } from './internship-engagement.resolver';
import { InternshipPositionResolver } from './internship-position.resolver';
import { LanguageEngagementResolver } from './language-engagement.resolver';
import { AddMilestoneReachedMigration } from './migrations/add-milestone-reached.migration';
import { FixNullMethodologiesMigration } from './migrations/fix-null-methodologies.migration';
import { EngagementProductConnectionResolver } from './product-connection.resolver';

Expand All @@ -44,6 +45,7 @@ import { EngagementProductConnectionResolver } from './product-connection.resolv
EngagementLoader,
...Object.values(handlers),
FixNullMethodologiesMigration,
AddMilestoneReachedMigration,
],
exports: [EngagementService, EngagementRepository],
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { BaseMigration, Migration } from '~/core/database';
import { LanguageEngagement } from '../dto';

@Migration('2024-12-12T10:00:00')
export class AddMilestoneReachedMigration extends BaseMigration {
async up() {
await this.addProperty(LanguageEngagement, 'milestoneReached', 'Unknown');
}
}
1 change: 1 addition & 0 deletions src/components/language/dto/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from './language.dto';
export * from './update-language.dto';
export * from './delete-language.dto';
export * from './first-scripture.dto';
export * from './language-milestone.enum';
15 changes: 15 additions & 0 deletions src/components/language/dto/language-milestone.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { ObjectType } from '@nestjs/graphql';
import { EnumType, makeEnum, SecuredEnum } from '~/common';

export type LanguageMilestone = EnumType<typeof LanguageMilestone>;
export const LanguageMilestone = makeEnum({
name: 'LanguageMilestone',
values: ['Unknown', 'None', 'OldTestament', 'NewTestament', 'FullBible'],
});

@ObjectType({
description: SecuredEnum.descriptionFor('a language milestone'),
})
export class SecuredLanguageMilestone extends SecuredEnum(LanguageMilestone, {
nullable: true,
}) {}

0 comments on commit 993aa9d

Please sign in to comment.