Skip to content

Commit

Permalink
Add all flowObject properties
Browse files Browse the repository at this point in the history
  • Loading branch information
manelcecs committed Jan 10, 2024
1 parent a4be794 commit 7d6ca42
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 14 deletions.
1 change: 0 additions & 1 deletion src/domain-services/flows/model.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { type Database } from '@unocha/hpc-api-core/src/db';
import { type FlowId } from '@unocha/hpc-api-core/src/db/models/flow';
import { type InstanceDataOfModel } from '@unocha/hpc-api-core/src/db/util/raw-model';
import Knex from 'knex';
import { type SortOrder } from '../../utils/graphql/pagination';

export type FlowEntity = InstanceDataOfModel<Database['flow']>;
Expand Down
44 changes: 37 additions & 7 deletions src/domain-services/location/graphql/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Brand } from '@unocha/hpc-api-core/src/util/types';
import { MaxLength } from 'class-validator';
import { Field, ID, Int, ObjectType, registerEnumType } from 'type-graphql';
import { Field, ID, ObjectType, registerEnumType } from 'type-graphql';
import { BaseType } from '../../../utils/graphql/base-types';

export enum LocationStatus {
Expand All @@ -25,7 +25,7 @@ export default class Location extends BaseType {
@MaxLength(255)
name?: string;

@Field(() => Int)
@Field(() => Number)
adminLevel: number; // Accidentally optional

@Field({ nullable: true })
Expand All @@ -34,7 +34,7 @@ export default class Location extends BaseType {
@Field({ nullable: true })
longitude?: number;

@Field(() => Int, { nullable: true })
@Field(() => Number, { nullable: true })
parentId?: number;

@Field({ nullable: true })
Expand All @@ -47,7 +47,7 @@ export default class Location extends BaseType {
@Field(() => LocationStatus)
status?: LocationStatus; // Accidentally optional

@Field(() => Int, { nullable: true })
@Field(() => Number, { nullable: true })
validOn?: number;

@Field({ defaultValue: true })
Expand All @@ -56,12 +56,42 @@ export default class Location extends BaseType {

@ObjectType()
export class BaseLocation extends BaseType {
@Field({ nullable: false })
@Field({ nullable: true })
id: number;

@Field(() => String, { nullable: false })
@Field(() => String, { nullable: true })
name: string | null;

@Field({ nullable: false })
@Field({ nullable: true })
direction: string;

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

@Field(() => Number)
adminLevel: number | null; // Accidentally optional

@Field(() => Number, { nullable: true })
latitude: number | null;

@Field(() => Number, { nullable: true })
longitude: number | null;

@Field(() => Number, { nullable: true })
parentId: number | null;

@Field(() => String, { nullable: true })
iso3: string | null;

@Field(() => String, { nullable: true })
pcode: string | null;

@Field(() => String)
status: string | null; // Accidentally optional

@Field(() => Number, { nullable: true })
validOn: string | number | null;

@Field({ defaultValue: true })
itosSync: boolean; // Accidentally optional
}
11 changes: 10 additions & 1 deletion src/domain-services/location/location-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,22 @@ export class LocationService {
private mapLocationsToFlowLocations(
location: InstanceDataOfModel<Database['location']>,
locationFO: InstanceDataOfModel<Database['flowObject']>
) {
): BaseLocation {
return {
id: location.id,
name: location.name,
direction: locationFO.refDirection,
createdAt: location.createdAt.toISOString(),
updatedAt: location.updatedAt.toISOString(),
adminLevel: location.adminLevel,
latitude: location.latitude,
longitude: location.longitude,
parentId: location.parentId,
iso3: location.iso3,
status: location.status,
validOn: location.validOn,
itosSync: location.itosSync,
pcode: location.pcode,
};
}
}
31 changes: 29 additions & 2 deletions src/domain-services/organizations/graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,38 @@ export class Organization extends BaseType {
id: number;

@Field({ nullable: true })
direction: string;
name: string;

@Field({ nullable: true })
name: string;
direction: string;

@Field({ nullable: true })
abbreviation: string;

@Field({ nullable: true })
url: string;

@Field({ nullable: true })
parentID: number;

@Field({ nullable: true })
nativeName: string;

@Field({ nullable: true })
comments: string;

@Field({ nullable: true })
collectiveInd: string;

@Field({ nullable: true })
active: boolean;

@Field({ nullable: true })
newOrganisationId: number;

@Field({ nullable: true })
verified: boolean;

@Field({ nullable: true })
notes: string;
}
9 changes: 9 additions & 0 deletions src/domain-services/organizations/organization-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ export class OrganizationService {
createdAt: organization.createdAt.toISOString(),
updatedAt: organization.updatedAt.toISOString(),
abbreviation: organization.abbreviation,
url: organization.url,
parentID: organization.parentID,
nativeName: organization.nativeName,
comments: organization.comments,
collectiveInd: organization.collectiveInd,
active: organization.active,
newOrganisationId: organization.newOrganisationId,
verified: organization.verified,
notes: organization.notes,
};
}
}
42 changes: 39 additions & 3 deletions src/domain-services/plans/graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,48 @@ export default class Plan {

@ObjectType()
export class BasePlan extends BaseType {
@Field({ nullable: false })
@Field({ nullable: true })
id: number;

@Field({ nullable: false })
@Field({ nullable: true })
name: string;

@Field({ nullable: false })
@Field({ nullable: true })
direction: string;

@Field({ nullable: true })
startDate: string;

@Field({ nullable: true })
endDate: string;

@Field(() => String, { nullable: true })
comments: string | null;

@Field({ nullable: true })
isForHPCProjects: boolean;

@Field(() => String, { nullable: true })
code: string | null;

@Field(() => String, { nullable: true })
customLocationCode: string | null;

@Field(() => Number, { nullable: true })
currentReportingPeriodId: number | null;

@Field({ nullable: true })
currentVersion: boolean;

@Field({ nullable: true })
latestVersion: boolean;

@Field({ nullable: true })
latestTaggedVersion: boolean;

@Field(() => Number, { nullable: true })
lastPublishedReportingPeriodId: number | null;

@Field(() => String, { nullable: true })
clusterSelectionType: string | null;
}
13 changes: 13 additions & 0 deletions src/domain-services/plans/plan-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,19 @@ export class PlanService {
createdAt: plan.createdAt.toISOString(),
updatedAt: plan.updatedAt.toISOString(),
direction: direction ?? '',
startDate: planVersion.startDate.toISOString(),
endDate: planVersion.endDate.toISOString(),
comments: planVersion.comments,
isForHPCProjects: planVersion.isForHPCProjects,
code: planVersion.code,
customLocationCode: planVersion.customLocationCode,
currentReportingPeriodId: planVersion.currentReportingPeriodId,
currentVersion: planVersion.currentVersion,
latestVersion: planVersion.latestVersion,
latestTaggedVersion: planVersion.latestTaggedVersion,
lastPublishedReportingPeriodId:
planVersion.lastPublishedReportingPeriodId,
clusterSelectionType: planVersion.clusterSelectionType,
};
}
}

0 comments on commit 7d6ca42

Please sign in to comment.