Skip to content

Commit

Permalink
EdgeDB Engagement Repo adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanjnelson committed Jun 7, 2024
1 parent 4b5d831 commit acee2b1
Showing 1 changed file with 13 additions and 26 deletions.
39 changes: 13 additions & 26 deletions src/components/engagement/engagement.edgedb.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,29 +121,7 @@ export class EngagementEdgeDBRepository
_session: Session,
_changeset?: ID,
) {
const { projectId, internId, mentorId, countryOfOriginId, ...props } =
input;

const project = e.cast(e.InternshipProject, e.uuid(projectId));
const intern = e.cast(e.User, e.uuid(internId));
const mentor = mentorId ? e.cast(e.User, e.uuid(mentorId)) : e.set();
const countryOfOrigin = countryOfOriginId
? e.cast(e.Location, e.uuid(countryOfOriginId))
: e.set();

const createdInternshipEngagement = e.insert(e.InternshipEngagement, {
project: project as any,
projectContext: project.projectContext,
intern: intern,
mentor: mentor,
countryOfOrigin: countryOfOrigin,
growthPlan: undefined as any, //TODO
...props,
});

const query = e.select(createdInternshipEngagement, internshipHydrate);

return await this.db.run(query);
return await this.concretes.InternshipEngagement.create(input);
}

get getActualLanguageChanges() {
Expand Down Expand Up @@ -199,15 +177,24 @@ export class EngagementEdgeDBRepository
projectId: ID,
excludes: EngagementStatus[] = [],
) {
const project = e.cast(e.Project, e.uuid(projectId));
const translationProject = e.cast(e.TranslationProject, e.uuid(projectId));
const internshipProject = e.cast(e.InternshipProject, e.uuid(projectId));

const ongoingExceptExclusions = e.cast(
e.Engagement.Status,
e.set(...difference([...EngagementStatus.Ongoing], excludes)),
);

const engagements = e.select(project.engagements, (eng) => ({
filter: e.op(eng.status, 'in', ongoingExceptExclusions),
const engagements = e.select(e.Engagement, (eng) => ({
filter: e.op(
e.op(
e.op(eng.project, '=', translationProject),
'or',
e.op(eng.project, '=', internshipProject),
),
'and',
e.op(eng.status, 'in', ongoingExceptExclusions),
),
}));

return await this.db.run(engagements.id);
Expand Down

0 comments on commit acee2b1

Please sign in to comment.