Skip to content
Open
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: 2 additions & 2 deletions src/academicyears/academicyears.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { AcademicyearsController } from "./academicyears.controller";
import { TypeOrmModule } from "@nestjs/typeorm";
import { AcademicYear } from "./entities/academicyears-entity";
import { AcademicYearService } from "./academicyears.service";
import { Tenants } from "src/userTenantMapping/entities/tenant.entity";
import { Tenant } from "src/tenant/entities/tenent.entity";

@Module({
imports: [TypeOrmModule.forFeature([AcademicYear, Tenants])],
imports: [TypeOrmModule.forFeature([AcademicYear, Tenant])],
providers: [AcademicYearService],
controllers: [AcademicyearsController],
exports: [AcademicYearService],
Expand Down
6 changes: 3 additions & 3 deletions src/academicyears/academicyears.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import { API_RESPONSES } from "@utils/response.messages";
import { APIID } from "@utils/api-id.config";
import APIResponse from "src/common/responses/response";
import { AcademicYearSearchDto } from "./dto/academicyears-search.dto";
import { Tenants } from "src/userTenantMapping/entities/tenant.entity";
import { Tenant } from "src/tenant/entities/tenent.entity";

@Injectable()
export class AcademicYearService {
constructor(
@InjectRepository(AcademicYear)
private readonly academicYearRespository: Repository<AcademicYear>,
@InjectRepository(Tenants)
private readonly tenantRepository: Repository<Tenants>
@InjectRepository(Tenant)
private readonly tenantRepository: Repository<Tenant>
) { }

public async createAcademicYear(
Expand Down
38 changes: 20 additions & 18 deletions src/academicyears/entities/academicyears-entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,40 @@ export class AcademicYear {
@PrimaryGeneratedColumn("uuid")
id: string;

@Column({ type: "date", name: "startDate" })
@Column({ type: "date", name: "startDate", nullable: false })
startDate: string;

@Column({ type: "date", name: "endDate" })
@Column({ type: "date", name: "endDate", nullable: false })
endDate: string;

@Column({ type: "varchar", length: 15, name: "session" })
session: string;
@Column({ type: "varchar", length: 15, name: "session", nullable: true })
session: string | null;

@CreateDateColumn({
type: "timestamp",
type: "timestamptz",
name: "createdAt",
default: () => "CURRENT_TIMESTAMP",
default: () => "now()",
nullable: true,
})
createdAt: Date;
createdAt: Date | null;

@UpdateDateColumn({
type: "timestamp",
type: "timestamptz",
name: "updatedAt",
default: () => "CURRENT_TIMESTAMP",
default: () => "now()",
nullable: true,
})
updatedAt: Date;
updatedAt: Date | null;

@Column({ type: "uuid", nullable: true })
createdBy: string;
@Column({ type: "boolean", name: "isActive", default: true, nullable: true })
isActive: boolean | null;

@Column({ type: "uuid", nullable: true })
updatedBy: string;
@Column({ type: "uuid", name: "tenantId", nullable: true })
tenantId: string | null;

@Column({ type: "boolean", name: "isActive", default: true })
isActive: boolean;
@Column({ type: "uuid", name: "updatedBy", nullable: true })
updatedBy: string | null;

@Column("uuid", { nullable: false })
tenantId: string;
@Column({ type: "uuid", name: "createdBy", nullable: true })
createdBy: string | null;
}
16 changes: 10 additions & 6 deletions src/automatic-member/entity/automatic-member.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@ export class AutomaticMember {
@PrimaryGeneratedColumn('uuid')
id: string;

@Column('uuid')
@Column('uuid', { nullable: false })
userId: string;

@Column('jsonb')
@Column('jsonb', { nullable: false })
rules: any;

@Column('uuid')
@Column('uuid', { nullable: false })
tenantId: string;

@Column({ default: true })
@Column({ type: "bool", default: true, nullable: false })
isActive: boolean;

@CreateDateColumn()
createdAt: Date;
@CreateDateColumn({
type: "timestamp",
default: () => "CURRENT_TIMESTAMP",
nullable: true,
})
createdAt: Date | null;
}
4 changes: 2 additions & 2 deletions src/cohort/cohort.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { AcademicYearService } from "src/academicyears/academicyears.service";
import { AcademicYear } from "src/academicyears/entities/academicyears-entity";
import { CohortMembersService } from "src/cohortMembers/cohortMembers.service";
import { User } from "src/user/entities/user-entity";
import { Tenants } from "src/userTenantMapping/entities/tenant.entity";
import { Tenant } from "src/tenant/entities/tenent.entity";
import { AutomaticMember } from "src/automatic-member/entity/automatic-member.entity";
import { AutomaticMemberService } from "src/automatic-member/automatic-member.service";
import { KafkaService } from "../kafka/kafka.service";
Expand All @@ -39,7 +39,7 @@ import { KafkaModule } from "../kafka/kafka.module";
CohortAcademicYear,
AcademicYear,
User,
Tenants,
Tenant,
AutomaticMember
]),
HttpModule,
Expand Down
70 changes: 36 additions & 34 deletions src/cohort/entities/cohort.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,51 +13,53 @@ export class Cohort {
@PrimaryGeneratedColumn("uuid")
cohortId: string;

@Column({ nullable: true })
parentId: string;
@CreateDateColumn({
type: "timestamptz",
default: () => "now()",
nullable: false,
})
createdAt: Date;

@Column({ nullable: true })
name: string;
@UpdateDateColumn({
type: "timestamptz",
default: () => "now()",
nullable: false,
})
updatedAt: Date;

@Column({ nullable: true })
type: string;
@Column({ type: "bool", nullable: false })
attendanceCaptureImage: boolean;

@Column()
status: string;
@Column({ type: "varchar", nullable: true })
parentId: string | null;

@Column({ type: "json", nullable: true })
image: string[]; // JSON field to store array of program images
@Column({ type: "varchar", length: 255, nullable: true })
name: string | null;

@Column({ nullable: true })
referenceId: string;
@Column({ type: "varchar", length: 255, nullable: true })
type: string | null;

@Column({ nullable: true })
metadata: string;
@Column({ type: "jsonb", nullable: true })
image: any;

@Column({ nullable: true })
tenantId: string;
@Column({ type: "varchar", nullable: true })
referenceId: string | null;

@Column({ nullable: true })
programId: string;
@Column({ type: "varchar", nullable: true })
metadata: string | null;

@Column()
attendanceCaptureImage: boolean;
@Column({ type: "uuid", nullable: false })
tenantId: string;

@CreateDateColumn({
type: "timestamp with time zone",
default: () => "CURRENT_TIMESTAMP",
})
createdAt: Date;
@Column({ type: "varchar", nullable: true })
programId: string | null;

@UpdateDateColumn({
type: "timestamp with time zone",
default: () => "CURRENT_TIMESTAMP",
})
updatedAt: Date;
@Column({ type: "uuid", nullable: true })
createdBy: string | null;

@Column()
createdBy: string;
@Column({ type: "uuid", nullable: true })
updatedBy: string | null;

@Column()
updatedBy: string;
@Column({ type: "varchar", nullable: true })
status: string | null;
}
4 changes: 2 additions & 2 deletions src/cohortAcademicYear/cohortAcademicYear.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { CohortAcademicYearController } from "./cohortAcademicYear.controller";
import { TypeOrmModule } from "@nestjs/typeorm";
import { Cohort } from "src/cohort/entities/cohort.entity";
import { AcademicYear } from "src/academicyears/entities/academicyears-entity";
import { Tenants } from "src/userTenantMapping/entities/tenant.entity";
import { Tenant } from "src/tenant/entities/tenent.entity";
import { AcademicyearsModule } from "src/academicyears/academicyears.module";


Expand All @@ -16,7 +16,7 @@ import { AcademicyearsModule } from "src/academicyears/academicyears.module";
CohortAcademicYear,
Cohort,
AcademicYear,
Tenants
Tenant
]),
],
controllers: [CohortAcademicYearController],
Expand Down
30 changes: 19 additions & 11 deletions src/cohortAcademicYear/entities/cohortAcademicYear.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,29 @@ export class CohortAcademicYear {
@PrimaryGeneratedColumn("uuid")
cohortAcademicYearId: string;

@Column({ type: "uuid" })
@Column({ type: "uuid", nullable: false })
academicYearId: string;

@Column({ type: "uuid", nullable: false })
cohortId: string;

@Column({ type: "uuid" })
academicYearId: string;
@CreateDateColumn({
type: "timestamptz",
default: () => "now()",
nullable: true,
})
createdAt: Date | null;

@Column({ type: "uuid" })
@UpdateDateColumn({
type: "timestamptz",
default: () => "now()",
nullable: true,
})
updatedAt: Date | null;

@Column({ type: "uuid", nullable: false })
createdBy: string;

@Column({ type: "uuid" })
@Column({ type: "uuid", nullable: false })
updatedBy: string;

@CreateDateColumn({ type: "date", default: () => "CURRENT_DATE" })
createdAt: Date;

@UpdateDateColumn({ type: "date", default: () => "CURRENT_DATE" })
updatedAt: Date;
}
4 changes: 2 additions & 2 deletions src/cohortMembers/cohortMembers.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { User } from "src/user/entities/user-entity";
import { Cohort } from "src/cohort/entities/cohort.entity";
import { CohortAcademicYear } from "src/cohortAcademicYear/entities/cohortAcademicYear.entity";
import { AcademicYear } from "src/academicyears/entities/academicyears-entity";
import { Tenants } from "src/userTenantMapping/entities/tenant.entity";
import { Tenant } from "src/tenant/entities/tenent.entity";
import { KafkaModule } from "src/kafka/kafka.module";
import { FieldsModule } from "src/fields/fields.module";
import { UserModule } from "src/user/user.module";
Expand All @@ -25,7 +25,7 @@ import { NotificationRequest } from "src/common/utils/notification.axios";
Cohort,
CohortAcademicYear,
AcademicYear,
Tenants
Tenant
]),
HttpModule,
FieldsModule,
Expand Down
35 changes: 18 additions & 17 deletions src/cohortMembers/entities/cohort-member.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,35 @@ export class CohortMembers {
@PrimaryGeneratedColumn("uuid")
cohortMembershipId: string;

@Column({ type: "uuid" })
cohortId: string;
@CreateDateColumn({ type: "date", default: () => "now()", nullable: true })
createdAt: Date | null;

@Column({ type: "uuid" })
cohortAcademicYearId: string;
@UpdateDateColumn({ type: "date", default: () => "now()", nullable: true })
updatedAt: Date | null;

@Column({ type: "uuid" })
userId: string;

@CreateDateColumn({ type: "date", default: () => "CURRENT_DATE" })
createdAt: Date;

@UpdateDateColumn({ type: "date", default: () => "CURRENT_DATE" })
updatedAt: Date;
@Column({ type: "uuid", nullable: true })
cohortId: string | null;

@Column({ type: "uuid", nullable: true })
createdBy: string;
userId: string | null;

@Column({ type: "uuid", nullable: true })
updatedBy: string;
createdBy: string | null;

@Column({ type: "varchar" })
statusReason: string;
@Column({ type: "uuid", nullable: true })
updatedBy: string | null;

@Column({
type: "enum",
enum: MemberStatus,
default: MemberStatus.ACTIVE,
nullable: true,
})
status: MemberStatus;
status: MemberStatus | null;

@Column({ type: "text", nullable: true })
statusReason: string | null;

@Column({ type: "uuid", nullable: true })
cohortAcademicYearId: string | null;
}
6 changes: 6 additions & 0 deletions src/common/database.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ import { User } from "src/user/entities/user-entity";
// User
// ],
autoLoadEntities: true,
// Both synchronize and migrations enabled
// - synchronize: Auto-syncs entity changes (will error if structure differs - that's expected)
// - migrations: Used for creating new tables via migration scripts
synchronize: true,
migrations: ['dist/migrations/*.js'],
migrationsRun: true, // Auto-run migrations on startup
extra: {
max: 20, // Number of connections in the pool (default is 10)
idleTimeoutMillis: 30000, // 30 seconds
Expand Down
6 changes: 5 additions & 1 deletion src/fields/dto/field-values-create.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ export class FieldValuesCreateDto {

//value
@Expose()
value: string;
value: string[];

constructor(obj: any) {
Object.assign(this, obj);
// Normalize value: convert string to array, keep array as is
if (this.value !== undefined && this.value !== null) {
this.value = Array.isArray(this.value) ? this.value : [this.value];
}
}
}
Loading