Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LanguageEngagement.usingAIAssistedTranslation #3345

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion dbschema/engagement.esdl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions dbschema/migrations/00011-m1wwg76.edgeql

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

11 changes: 11 additions & 0 deletions src/common/secured-property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,14 @@ export abstract class SecuredFloatNullable extends SecuredProperty<
export abstract class SecuredBoolean extends SecuredProperty<boolean>(
GraphQLBoolean,
) {}

@ObjectType({
description: SecuredProperty.descriptionFor('a boolean or null'),
})
export abstract class SecuredBooleanNullable extends SecuredProperty<
boolean,
boolean,
true
>(GraphQLBoolean, {
nullable: true,
}) {}
3 changes: 3 additions & 0 deletions src/components/engagement/dto/create-engagement.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 5 additions & 1 deletion src/components/engagement/dto/engagement.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
ResourceRelationsShape,
Secured,
SecuredBoolean,
SecuredBooleanNullable,
SecuredDateNullable,
SecuredDateTimeNullable,
SecuredProps,
Expand Down Expand Up @@ -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 })
Expand Down
3 changes: 3 additions & 0 deletions src/components/engagement/dto/update-engagement.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const languageExtraHydrate = {
pnp: true,
historicGoal: true,
milestoneReached: true,
usingAIAssistedTranslation: 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 { 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';
Expand Down Expand Up @@ -46,6 +47,7 @@ import { EngagementProductConnectionResolver } from './product-connection.resolv
...Object.values(handlers),
FixNullMethodologiesMigration,
AddMilestoneReachedMigration,
AddAiAssistFlagMigration,
],
exports: [EngagementService, EngagementRepository],
})
Expand Down
3 changes: 3 additions & 0 deletions src/components/engagement/engagement.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
);
}
}
Loading