diff --git a/dbschema/engagement.esdl b/dbschema/engagement.esdl index fac1c1b80d..20409b67be 100644 --- a/dbschema/engagement.esdl +++ b/dbschema/engagement.esdl @@ -84,7 +84,9 @@ module default { milestoneReached: Language::Milestone { default := Language::Milestone.Unknown; }; - + + usingAIAssistedTranslation: bool; + # I want ceremony to be automatically created when engagement is created. # Using computed & trigger to do this, because properties with default expressions # cannot refer to links of inserted object. diff --git a/dbschema/migrations/00011-m1wwg76.edgeql b/dbschema/migrations/00011-m1wwg76.edgeql new file mode 100644 index 0000000000..08802e4ff4 --- /dev/null +++ b/dbschema/migrations/00011-m1wwg76.edgeql @@ -0,0 +1,7 @@ +CREATE MIGRATION m1wwg76ehuufntgxnrnfhvejnb5zvc33raag4o62zud3uhoyq44rbq + ONTO m1zbd7jjxvlolupx2hntj4qjunhqxyyd2ryjzwjczp67il32vtbmfa +{ + ALTER TYPE default::LanguageEngagement { + CREATE PROPERTY usingAIAssistedTranslation: std::bool; + }; +}; diff --git a/src/common/secured-property.ts b/src/common/secured-property.ts index 3e14a85e0c..2746210881 100644 --- a/src/common/secured-property.ts +++ b/src/common/secured-property.ts @@ -277,3 +277,14 @@ export abstract class SecuredFloatNullable extends SecuredProperty< export abstract class SecuredBoolean extends SecuredProperty( GraphQLBoolean, ) {} + +@ObjectType({ + description: SecuredProperty.descriptionFor('a boolean or null'), +}) +export abstract class SecuredBooleanNullable extends SecuredProperty< + boolean, + boolean, + true +>(GraphQLBoolean, { + nullable: true, +}) {} diff --git a/src/components/engagement/dto/create-engagement.dto.ts b/src/components/engagement/dto/create-engagement.dto.ts index 1273e60ca5..4c7976d95a 100644 --- a/src/components/engagement/dto/create-engagement.dto.ts +++ b/src/components/engagement/dto/create-engagement.dto.ts @@ -74,6 +74,9 @@ export abstract class CreateLanguageEngagement extends CreateEngagement { @Field(() => LanguageMilestone, { nullable: true }) readonly milestoneReached?: LanguageMilestone; + + @Field(() => Boolean, { nullable: true }) + readonly usingAIAssistedTranslation?: boolean | null; } @InputType() diff --git a/src/components/engagement/dto/engagement.dto.ts b/src/components/engagement/dto/engagement.dto.ts index ba27b7f51b..951dbcc0d0 100644 --- a/src/components/engagement/dto/engagement.dto.ts +++ b/src/components/engagement/dto/engagement.dto.ts @@ -14,6 +14,7 @@ import { ResourceRelationsShape, Secured, SecuredBoolean, + SecuredBooleanNullable, SecuredDateNullable, SecuredDateTimeNullable, SecuredProps, @@ -191,8 +192,11 @@ export class LanguageEngagement extends Engagement { @Field() readonly historicGoal: SecuredStringNullable; - @Field(() => SecuredLanguageMilestone) + @Field() readonly milestoneReached: SecuredLanguageMilestone; + + @Field() + readonly usingAIAssistedTranslation: SecuredBooleanNullable; } @RegisterResource({ db: e.InternshipEngagement }) diff --git a/src/components/engagement/dto/update-engagement.dto.ts b/src/components/engagement/dto/update-engagement.dto.ts index 74dbcabd47..d2aa8f39f6 100644 --- a/src/components/engagement/dto/update-engagement.dto.ts +++ b/src/components/engagement/dto/update-engagement.dto.ts @@ -80,6 +80,9 @@ export abstract class UpdateLanguageEngagement extends UpdateEngagement { @Field(() => LanguageMilestone, { nullable: true }) readonly milestoneReached?: LanguageMilestone; + + @Field(() => Boolean, { nullable: true }) + readonly usingAIAssistedTranslation?: boolean | null; } @InputType() diff --git a/src/components/engagement/engagement.edgedb.repository.ts b/src/components/engagement/engagement.edgedb.repository.ts index 75666989fb..af0943f91f 100644 --- a/src/components/engagement/engagement.edgedb.repository.ts +++ b/src/components/engagement/engagement.edgedb.repository.ts @@ -46,6 +46,7 @@ const languageExtraHydrate = { pnp: true, historicGoal: true, milestoneReached: true, + usingAIAssistedTranslation: true, } as const; const internshipExtraHydrate = { diff --git a/src/components/engagement/engagement.module.ts b/src/components/engagement/engagement.module.ts index 47040dac90..c410db41d4 100644 --- a/src/components/engagement/engagement.module.ts +++ b/src/components/engagement/engagement.module.ts @@ -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 { AddAiAssistFlagMigration } from './migrations/add-ai-assist-flag.migration'; import { AddMilestoneReachedMigration } from './migrations/add-milestone-reached.migration'; import { FixNullMethodologiesMigration } from './migrations/fix-null-methodologies.migration'; import { EngagementProductConnectionResolver } from './product-connection.resolver'; @@ -46,6 +47,7 @@ import { EngagementProductConnectionResolver } from './product-connection.resolv ...Object.values(handlers), FixNullMethodologiesMigration, AddMilestoneReachedMigration, + AddAiAssistFlagMigration, ], exports: [EngagementService, EngagementRepository], }) diff --git a/src/components/engagement/engagement.repository.ts b/src/components/engagement/engagement.repository.ts index 8dac6021c3..c1b69ebd00 100644 --- a/src/components/engagement/engagement.repository.ts +++ b/src/components/engagement/engagement.repository.ts @@ -51,6 +51,7 @@ import { import { Privileges } from '../authorization'; import { FileService } from '../file'; import { FileId } from '../file/dto'; +import { LanguageMilestone } from '../language/dto'; import { languageFilters, languageSorters, @@ -227,6 +228,8 @@ export class EngagementRepository extends CommonRepository { statusModifiedAt: undefined, lastSuspendedAt: undefined, lastReactivatedAt: undefined, + milestoneReached: input.milestoneReached || LanguageMilestone.Unknown, + usingAIAssistedTranslation: input.usingAIAssistedTranslation || null, modifiedAt: DateTime.local(), canDelete: true, }; diff --git a/src/components/engagement/migrations/add-ai-assist-flag.migration.ts b/src/components/engagement/migrations/add-ai-assist-flag.migration.ts new file mode 100644 index 0000000000..beeb851d0d --- /dev/null +++ b/src/components/engagement/migrations/add-ai-assist-flag.migration.ts @@ -0,0 +1,13 @@ +import { BaseMigration, Migration } from '~/core/database'; +import { LanguageEngagement } from '../dto'; + +@Migration('2024-12-18T12:00:00') +export class AddAiAssistFlagMigration extends BaseMigration { + async up() { + await this.addProperty( + LanguageEngagement, + 'usingAIAssistedTranslation', + null, + ); + } +}