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

Fix trainee attendance #385

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
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
29 changes: 29 additions & 0 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"@graphql-tools/utils": "^10.0.4",
"@octokit/graphql": "^7.0.1",
"@octokit/rest": "^19.0.13",
"@types/node-cron": "^3.0.11",
"apollo-server": "^3.13.0",
"axios": "^1.7.7",
"bcryptjs": "^2.4.3",
Expand All @@ -79,6 +80,7 @@
"jsonwebtoken": "^9.0.2",
"mongodb": "^4.17.1",
"mongoose": "^6.6.1",
"node-cron": "^3.0.3",
"node-fetch": "^2.6.12",
"nodemailer": "^6.7.8",
"normalize-mongoose": "^1.0.0",
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import { IResolvers } from '@graphql-tools/utils'
import invitationSchema from './schema/invitation.schema'
import TableViewInvitationResolver from './resolvers/TableViewInvitationResolver'
import eventSchema from './schema/event.schema'
import './utils/cron-jobs/team-jobs'

const PORT: number = parseInt(process.env.PORT!) || 4000

Expand Down
30 changes: 22 additions & 8 deletions src/models/attendance.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ const AttendanceSchema = new Schema({

teams: [
{
date: {
type: Date,
required: false,
default: () => new Date(),
},
team: {
type: mongoose.Types.ObjectId,
type: mongoose.Schema.Types.ObjectId,
ref: 'Team',
required: true
},
Expand All @@ -34,24 +39,33 @@ const AttendanceSchema = new Schema({
day: {
type: String,
enum: ['mon', 'tue', 'wed', 'thu', 'fri'],
required: true
required: true
},
date: {
type: Date,
required: true
required: true
},
score: {
type: String,
enum: ['0', '1', '2'],
required: true
enum: [0, 1, 2],
required: true
},
},
],
},
],}
],
}
],

})
}, { timestamps: true })

AttendanceSchema.index(
{
phase: 1,
cohort: 1,
createdAt: 1
},
{ unique: true }
);

const Attendance = mongoose.model('Attendance', AttendanceSchema)
export { Attendance }
8 changes: 8 additions & 0 deletions src/models/team.model.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import mongoose, { Schema } from 'mongoose'
import { User } from './user'
import { CohortInterface } from './cohort.model';
import { PhaseInterface } from './phase.model';

export interface TeamInterface {
_id: mongoose.Types.ObjectId;
name: string;
cohort?: CohortInterface;
phase?: PhaseInterface;
ttl?: mongoose.Types.ObjectId;
members: mongoose.Types.ObjectId[];
startingPhase: Date;
Expand Down Expand Up @@ -57,6 +60,11 @@ const teamSchema = new Schema(
type: mongoose.Types.ObjectId,
ref: 'Program',
},
isJobActive: {
type: Boolean,
default: true,
required: true,
},
},
{
statics: {
Expand Down
24 changes: 13 additions & 11 deletions src/models/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@ export interface UserStatus {
}

export interface UserInterface {
_id: mongoose.Types.ObjectId
email: string
password: string
role: string
team?: mongoose.Types.ObjectId
status: UserStatus
cohort?: mongoose.Types.ObjectId
program?: mongoose.Types.ObjectId
organizations: string[]
pushNotifications: boolean
emailNotifications: boolean
_id: mongoose.Types.ObjectId;
email: string;
password: string;
role: string;
team?: mongoose.Types.ObjectId;
status: UserStatus;
cohort?: mongoose.Types.ObjectId;
program?: mongoose.Types.ObjectId;
organizations: string[];
pushNotifications: boolean;
emailNotifications: boolean;
profile?: mongoose.Types.ObjectId;
ratings?: mongoose.Types.ObjectId[];
}

export enum RoleOfUser {
Expand Down
Loading
Loading