From d380869eb16c30d55df7e7e38c6b2a7fcaf593d3 Mon Sep 17 00:00:00 2001 From: migrenaa Date: Thu, 16 Jan 2025 23:42:48 +0400 Subject: [PATCH 1/9] Merge main into beta (#48) * added TP Contract Tx to ORg (#45) * txhash returned in get round by ID (#46) * totalFiat added to the response model of /me (#47) --- src/controllers/rounds.controller.ts | 24 ++++++++++++++++++++++++ src/entities/assessment/round.model.ts | 3 +++ src/models/rounds/roundDetails.model.ts | 1 + src/models/user/userDetails.model.ts | 3 +-- src/routers/rounds.router.ts | 1 + src/services/round.service.ts | 16 ++++++++++++++++ src/services/user.service.ts | 16 +++++++++++++++- 7 files changed, 61 insertions(+), 3 deletions(-) diff --git a/src/controllers/rounds.controller.ts b/src/controllers/rounds.controller.ts index 2aa1f32..0638f29 100644 --- a/src/controllers/rounds.controller.ts +++ b/src/controllers/rounds.controller.ts @@ -118,4 +118,28 @@ export class RoundsController { res.status(500).send('Internal Server Error'); } } + + + public addTokenMintTx = async (req: any, res: Response) => { + try { + const walletAddress = req.user.walletAddress; + const responseModel = await this.userService.getByWalletAddress(walletAddress); + if (!responseModel.data?.isAdmin) { + return res.status(401).json({ message: 'User is not an admin' }); + } + if (!responseModel.data?.organization?.id) { + return res.status(401).json({ message: 'User does not have an org' }); + } + + const txId = req.body.txId; + if (!txId) { + return res.status(400).json({ message: 'txId is required' }); + } + const result = await this.roundService.addTokenMintTx(req.params.roundId, txId); + res.status(result.statusCode).json(handleResponse(result)); + } catch (error) { + console.error('Error editing an org:', error); + res.status(500).send('Internal Server Error'); + } + } } diff --git a/src/entities/assessment/round.model.ts b/src/entities/assessment/round.model.ts index b528a70..7ae856e 100644 --- a/src/entities/assessment/round.model.ts +++ b/src/entities/assessment/round.model.ts @@ -19,6 +19,9 @@ export class Round { @Column({ type: 'timestamp' }) endDate!: Date; + @Column({ type: 'varchar', nullable: true }) + txHash!: string | null; + @Column({ type: 'timestamp', nullable: false }) compensationCycleStartDate!: Date; diff --git a/src/models/rounds/roundDetails.model.ts b/src/models/rounds/roundDetails.model.ts index 547d994..f0bfe61 100644 --- a/src/models/rounds/roundDetails.model.ts +++ b/src/models/rounds/roundDetails.model.ts @@ -6,6 +6,7 @@ export interface RoundResponseModel { status: RoundStatus; startDate: Date; endDate: Date; + txHash?: string | null; contributors: ContributorRoundModel[]; submittedAssessments: AssessmentResponseModel[]; compensationCycleStartDate: Date; diff --git a/src/models/user/userDetails.model.ts b/src/models/user/userDetails.model.ts index ccb26e6..606d474 100644 --- a/src/models/user/userDetails.model.ts +++ b/src/models/user/userDetails.model.ts @@ -1,5 +1,3 @@ -import { Role } from '../../entities/index.js'; - export interface UserResponseModel { id: string; walletAddress?: string; @@ -7,6 +5,7 @@ export interface UserResponseModel { email: string; profilePicture?: string; isAdmin: boolean; + totalFiat: number; organization?: OrganizationListModel | null; agreement?: AgreementModel | null; } diff --git a/src/routers/rounds.router.ts b/src/routers/rounds.router.ts index fe343ab..e3cfa71 100644 --- a/src/routers/rounds.router.ts +++ b/src/routers/rounds.router.ts @@ -20,6 +20,7 @@ export class RoundsRouter { this._router.post('/assess', jwtMiddleware, this.roundsController.addAssessment); this._router.get('/:roundId/assessments', jwtMiddleware, this.roundsController.getAssessments); this._router.post('/:roundId/assessments/remind', jwtMiddleware, this.roundsController.remind); + this._router.post('/:roundId/txHash', jwtMiddleware, this.roundsController.addTokenMintTx); } public get router(): Router { diff --git a/src/services/round.service.ts b/src/services/round.service.ts index 437966f..3c48f47 100644 --- a/src/services/round.service.ts +++ b/src/services/round.service.ts @@ -297,6 +297,7 @@ export class RoundService { : RoundStatus.Completed, startDate: round.startDate, endDate: round.endDate!, + txHash: round.txHash, compensationCycleStartDate: round.compensationCycleStartDate, compensationCycleEndDate: round.compensationCycleEndDate, contributors: Array.from(contributorsMap.values()), @@ -473,4 +474,19 @@ export class RoundService { return ResponseModel.createError(new Error('Could not send an email'), 400); } } + + public async addTokenMintTx(roundId: string, txHash: string): Promise> { + const round = await this.roundsRepository.findOne({ + where: { id: roundId } + }); + + if (!round) { + return ResponseModel.createError(new Error('Round not found'), 404); + } + + round.txHash = txHash; + await this.roundsRepository.save(round); + + return ResponseModel.createSuccess(null); + } } diff --git a/src/services/user.service.ts b/src/services/user.service.ts index 8209a87..e4348b8 100644 --- a/src/services/user.service.ts +++ b/src/services/user.service.ts @@ -9,7 +9,13 @@ import { SiweMessage } from 'siwe'; import { UserResponseModel } from '../models/user/userDetails.model.js'; import { EmailService } from './email.service.js'; import { AppDataSource } from '../data-source.js'; -import { Invitation, Organization, User, WalletNonce } from '../entities/index.js'; +import { + ContributorRoundCompensation, + Invitation, + Organization, + User, + WalletNonce +} from '../entities/index.js'; dotenv.config(); // Load the environment variables from .env @@ -110,6 +116,13 @@ export class UserService { return ResponseModel.createError(new Error('User not found'), 404); } + const contributionsRepo = AppDataSource.getRepository(ContributorRoundCompensation); + const contributions = await contributionsRepo.find({ where: { contributor: { id: user.id } } }); + let totalFiat = 0; + if (contributions.length > 0) { + totalFiat = contributions.reduce((acc, curr) => acc + curr.fiat, 0); + } + const responseModel: UserResponseModel = { id: user.id, walletAddress: user.address, @@ -117,6 +130,7 @@ export class UserService { email: user.email, profilePicture: user.profilePicture, isAdmin: user.isAdmin, + totalFiat: totalFiat, organization: user.organization && { id: user.organization!.id, logo: user.organization!.logo, From 42508e674c3beb68672e86aca045dfe9289dd1ff Mon Sep 17 00:00:00 2001 From: migrenaa Date: Fri, 24 Jan 2025 14:26:16 +0200 Subject: [PATCH 2/9] Merge main into beta - bugfixes of initial testing (#49) * added TP Contract Tx to ORg (#45) * txhash returned in get round by ID (#46) * totalFiat added to the response model of /me (#47) From c5fe2b1151c61ec4ae71c6ac0e1c9ea833bcae16 Mon Sep 17 00:00:00 2001 From: migrenaa Date: Mon, 3 Feb 2025 19:24:43 +0200 Subject: [PATCH 3/9] agreement id added to AgreementResponseModel (#53) (#54) --- src/models/user/userDetails.model.ts | 1 + src/services/organization.service.ts | 1 + src/services/user.service.ts | 1 + 3 files changed, 3 insertions(+) diff --git a/src/models/user/userDetails.model.ts b/src/models/user/userDetails.model.ts index 606d474..8ba8f4f 100644 --- a/src/models/user/userDetails.model.ts +++ b/src/models/user/userDetails.model.ts @@ -11,6 +11,7 @@ export interface UserResponseModel { } export interface AgreementModel { + id: string; roleName: string; responsibilities: string; marketRate: number; diff --git a/src/services/organization.service.ts b/src/services/organization.service.ts index bccf2b2..45b0522 100644 --- a/src/services/organization.service.ts +++ b/src/services/organization.service.ts @@ -187,6 +187,7 @@ export class OrganizationService { username: u.username, profilePicture: u.profilePicture, agreement: u.agreement && { + id: u.agreement.id, marketRate: u.agreement.marketRate, roleName: u.agreement.roleName, responsibilities: u.agreement.responsibilities, diff --git a/src/services/user.service.ts b/src/services/user.service.ts index af0c73c..9f817d3 100644 --- a/src/services/user.service.ts +++ b/src/services/user.service.ts @@ -137,6 +137,7 @@ export class UserService { name: user.organization!.name }, agreement: user.agreement && { + id: user.agreement.id, marketRate: user.agreement.marketRate, roleName: user.agreement.roleName, responsibilities: user.agreement.responsibilities, From 9b55930799eb96156a341ddc2edd06bcfa1e0ea5 Mon Sep 17 00:00:00 2001 From: migrenaa Date: Tue, 4 Feb 2025 15:08:49 +0200 Subject: [PATCH 4/9] main to beta (#56) * agreement id added to AgreementResponseModel (#53) * status field properly set (#55) --- src/services/round.service.ts | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/services/round.service.ts b/src/services/round.service.ts index 2cae5b2..35af2fb 100644 --- a/src/services/round.service.ts +++ b/src/services/round.service.ts @@ -34,9 +34,6 @@ export class RoundService { * Start rounds for all organizations that have the next round date set to today and have rounds activated */ public async createRounds(orgId?: string): Promise { - - console.log('[startRounds] Starting round creation...'); - console.log(`[startRounds] orgId: ${orgId}...`); const sevenDaysFromNow = endOfToday(); sevenDaysFromNow.setDate(sevenDaysFromNow.getDate() + 7); @@ -66,6 +63,7 @@ export class RoundService { .getMany(); } for (const org of orgs) { + console.log(`[${new Date()}][createRounds] Creating Round for : ${org.id}`); if (!org.compensationPeriod) { continue; @@ -95,7 +93,7 @@ export class RoundService { }); await this.roundsRepository.save(round); - console.log('[startRounds] Round created:', round.id); + console.log(`[${new Date()}][createRounds] Round Created : ${round.id}`); const o = await this.organizationRepository.findOne({ where: { id: org.id } @@ -114,13 +112,9 @@ export class RoundService { } } } - - console.log('[startRounds] Round creation completed.'); } public async completeRounds(): Promise { - - console.log('[completeRounds] Starting round completion...'); const nowUTC = new Date(); // Fetch rounds ending today, including required relations @@ -134,7 +128,7 @@ export class RoundService { for (const round of rounds) { - console.log('[completeRounds] Completing round:', round.id); + console.log(`[${new Date()}][completeRounds] Completing round: ${round.id}`); const par = round.organization.par; // Initialize a map to group scores by contributors (assessed) @@ -213,7 +207,6 @@ export class RoundService { await AppDataSource.manager.save(org); } - console.log('[completeRounds] Round completion completed.'); } public async getCurrentRound(organizationId: string): Promise> { @@ -298,13 +291,15 @@ export class RoundService { feedbackNegative: assessment.feedbackNegative })); + const nowUTC = new Date(); + // Create the round response const roundResponse: RoundResponseModel = { id: round.id, roundNumber: round.roundNumber, - status: round.startDate > beginningOfToday() + status: round.startDate > nowUTC ? RoundStatus.NotStarted - : round.endDate && round.endDate >= endOfToday() + : round.endDate && round.endDate >= nowUTC ? RoundStatus.InProgress : RoundStatus.Completed, startDate: round.startDate, @@ -343,13 +338,15 @@ export class RoundService { relations: ['assessments', 'assessments.assessor', 'assessments.assessed'] }); + const nowUTC = new Date(); + return ResponseModel.createSuccess(rounds.map((round) => { return { id: round.id, roundNumber: round.roundNumber, - status: round.startDate > beginningOfToday() + status: round.startDate > nowUTC ? RoundStatus.NotStarted - : round.endDate && round.endDate >= endOfToday() + : round.endDate && round.endDate >= nowUTC ? RoundStatus.InProgress : RoundStatus.Completed, startDate: round.startDate, @@ -358,6 +355,7 @@ export class RoundService { endDate: round.endDate! }; })); + } public async addAssessment(walletAddress: string, assessmentData: CreateAssessmentModel): Promise> { From 84ec85804bbaf8bf49420ce9339e9f8e50b2d171 Mon Sep 17 00:00:00 2001 From: migrenaa Date: Tue, 4 Feb 2025 15:20:18 +0200 Subject: [PATCH 5/9] current round fix (#58) * agreement id added to AgreementResponseModel (#53) * status field properly set (#55) * current round fetch fix (#57) --- src/services/round.service.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/services/round.service.ts b/src/services/round.service.ts index 35af2fb..272555a 100644 --- a/src/services/round.service.ts +++ b/src/services/round.service.ts @@ -210,11 +210,12 @@ export class RoundService { } public async getCurrentRound(organizationId: string): Promise> { + const utcNow = new Date(); const currentRound = await this.roundsRepository.findOne({ where: { organization: { id: organizationId }, - startDate: LessThanOrEqual(beginningOfToday()), - endDate: MoreThanOrEqual(endOfToday()) + startDate: LessThanOrEqual(utcNow), + endDate: MoreThanOrEqual(utcNow) }, relations: ['assessments', 'assessments.assessor', 'assessments.assessed'] }); From 0762d8e3ccc0661ab8df183d447c234a60b3806c Mon Sep 17 00:00:00 2001 From: migrenaa Date: Fri, 7 Feb 2025 16:00:47 +0200 Subject: [PATCH 6/9] hotfix (#60) * agreement id added to AgreementResponseModel (#53) * status field properly set (#55) * current round fetch fix (#57) * algorithm hotfix lack of assessment results in a score of 0 (#59) --- src/services/round.service.ts | 39 +++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/src/services/round.service.ts b/src/services/round.service.ts index 272555a..b77d25a 100644 --- a/src/services/round.service.ts +++ b/src/services/round.service.ts @@ -135,7 +135,8 @@ export class RoundService { const scoresByContributor = new Map 0 ? scores.cultureTotal / scores.cultureCount : 0; + comp.workScore = scores.workCount > 0 ? scores.workTotal / scores.workCount : 0; + comp.agreement_commitment = scores.commitment; comp.agreement_mr = scores.marketRate; comp.agreement_fiat = scores.fiat; - const finalScore = (comp.culturalScore + comp.workScore) / 2; + + // Calculate final score by averaging only valid scores + const validScores = [comp.culturalScore, comp.workScore].filter(score => score !== null); + const finalScore = validScores.length > 0 ? + validScores.reduce((a, b) => a! + b!, 0) / validScores.length : 0; + const baseSalary = (scores.commitment / 100) * scores.marketRate; const sam = (finalScore - 3) * ((par / 100) / 2); From 07360e969ed9cc325d87045bd44ee6032dd9af98 Mon Sep 17 00:00:00 2001 From: migrenaa Date: Fri, 7 Feb 2025 16:09:21 +0200 Subject: [PATCH 7/9] main into beta (#62) * agreement id added to AgreementResponseModel (#53) * status field properly set (#55) * current round fetch fix (#57) * algorithm hotfix lack of assessment results in a score of 0 (#59) * adding assessment fails check for current round (#61) --- src/services/organization.service.ts | 7 ++++--- src/services/round.service.ts | 10 ++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/services/organization.service.ts b/src/services/organization.service.ts index 45b0522..b560d39 100644 --- a/src/services/organization.service.ts +++ b/src/services/organization.service.ts @@ -8,7 +8,6 @@ import { Agreement, ContributorRoundCompensation, Invitation, Organization, Roun import { OrgDetailsModel, OrgModel } from '../models/org/editOrg.model.js'; import { CreateAgreementModel } from '../models/org/createAgreement.model.js'; import { - beginningOfToday, calculateAssessmentRoundEndTime, calculateAssessmentRoundStartTime } from '../utils/roundTime.util.js'; @@ -132,9 +131,11 @@ export class OrganizationService { organization: { id: org.id } } }); - const ongoingRound = rounds.find((r) => r.isCompleted === false && r.startDate <= beginningOfToday()); + + const utcNow = new Date(); + const ongoingRound = rounds.find((r) => r.isCompleted === false && r.startDate <= utcNow); if (!ongoingRound) { - const futureRound = rounds.find((r) => r.startDate >= beginningOfToday()); + const futureRound = rounds.find((r) => r.startDate >= utcNow); if (futureRound) { console.log('Updating existing round'); futureRound.startDate = calculateAssessmentRoundStartTime( diff --git a/src/services/round.service.ts b/src/services/round.service.ts index b77d25a..ac1e978 100644 --- a/src/services/round.service.ts +++ b/src/services/round.service.ts @@ -9,7 +9,6 @@ import { AssessmentResponseModel } from '../models/rounds/assessmentResponse.mod import { CreateAssessmentModel } from '../models/rounds/createAssessment.model.js'; import { CreatedResponseModel } from '../models/response_models/created_response_model.js'; import { - beginningOfToday, calculateAssessmentRoundEndTime, calculateAssessmentRoundStartTime, calculateNextCompensationPeriodStartDay, @@ -74,8 +73,10 @@ export class RoundService { org.compensationStartDay!, +org.assessmentStartDelayInDays! ); + + const utcNow = new Date(); - if (startRoundDate >= beginningOfToday() && startRoundDate <= sevenDaysFromNow) { + if (startRoundDate >= utcNow && startRoundDate <= sevenDaysFromNow) { const endRoundDate = calculateAssessmentRoundEndTime(startRoundDate, org.assessmentDurationInDays!); const nextCycleStartDate = calculateNextCompensationPeriodStartDay( @@ -391,11 +392,12 @@ export class RoundService { return ResponseModel.createError(new Error('Assessor not found'), 404); } + const utcNow = new Date(); const currentRound = await this.roundsRepository.findOne({ where: { organization: { id: assessor.organization.id }, - startDate: LessThanOrEqual(beginningOfToday()), - endDate: MoreThanOrEqual(endOfToday()) + startDate: LessThanOrEqual(utcNow), + endDate: MoreThanOrEqual(utcNow) } }); From 2a3231a429bbbeb83209c1fac8a356a62cba93e8 Mon Sep 17 00:00:00 2001 From: migrenaa Date: Wed, 12 Feb 2025 20:42:35 +0200 Subject: [PATCH 8/9] main into beta (#64) * agreement id added to AgreementResponseModel (#53) * status field properly set (#55) * current round fetch fix (#57) * algorithm hotfix lack of assessment results in a score of 0 (#59) * adding assessment fails check for current round (#61) * edit assessment; telegramHandle added; createdOn for user and org (#63) --- src/controllers/rounds.controller.ts | 23 +++++++++++ src/entities/org/organization.model.ts | 3 ++ src/entities/users/user.model.ts | 6 +++ src/models/user/userDetails.model.ts | 1 + src/models/user/userRegistration.model.ts | 2 + src/routers/rounds.router.ts | 1 + src/services/round.service.ts | 48 +++++++++++++++++++++++ src/services/user.service.ts | 4 +- 8 files changed, 87 insertions(+), 1 deletion(-) diff --git a/src/controllers/rounds.controller.ts b/src/controllers/rounds.controller.ts index 0638f29..47bd501 100644 --- a/src/controllers/rounds.controller.ts +++ b/src/controllers/rounds.controller.ts @@ -94,6 +94,29 @@ export class RoundsController { } } + + public editAssessment = async (req: any, res: Response) => { + try { + const model: CreateAssessmentModel = req.body!; + const isValid = createAssessmentSchema.validate(model); + if (isValid.error) { + return res.status(400).json({ message: isValid.error.message }); + } + + const assessmentId: string = req.params.assessmentId; + + const createdResponseModel = await this.roundService.editAssessment( + assessmentId, + (req as any).user.walletAddress, + model + ); + res.status(createdResponseModel.statusCode).json(handleResponse(createdResponseModel)); + } catch (error) { + console.error('Error editing an org:', error); + res.status(500).send('Internal Server Error'); + } + } + public getAssessments = async (req: any, res: Response) => { try { const roundId = req.params.roundId; diff --git a/src/entities/org/organization.model.ts b/src/entities/org/organization.model.ts index ef66739..1936b6b 100644 --- a/src/entities/org/organization.model.ts +++ b/src/entities/org/organization.model.ts @@ -23,6 +23,9 @@ export class Organization { @Column({ type: 'int', default: 0 }) totalFunds!: number; + @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }) + createdOn!: Date; + @Column('enum', { enum: CompensationPeriod, nullable: true }) compensationPeriod!: CompensationPeriod | null; diff --git a/src/entities/users/user.model.ts b/src/entities/users/user.model.ts index 3994d98..9dab90c 100644 --- a/src/entities/users/user.model.ts +++ b/src/entities/users/user.model.ts @@ -13,12 +13,18 @@ export class User { @Column({ type: 'varchar', length: 255, unique: true }) email!: string; + @Column({ type: 'varchar', length: 255, nullable: true }) + telegramHandle?: string; + @Column({ type: 'varchar', length: 255 }) username!: string; @Column({ type: 'varchar', nullable: true }) profilePicture?: string; + @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }) + registeredOn!: Date; + @OneToOne(() => Agreement, { nullable: true, cascade: true }) @JoinColumn({ name: 'agreement_id' }) agreement?: Relation; diff --git a/src/models/user/userDetails.model.ts b/src/models/user/userDetails.model.ts index 8ba8f4f..0b1fdbd 100644 --- a/src/models/user/userDetails.model.ts +++ b/src/models/user/userDetails.model.ts @@ -3,6 +3,7 @@ export interface UserResponseModel { walletAddress?: string; username: string; email: string; + telegramHandle?: string; profilePicture?: string; isAdmin: boolean; totalFiat: number; diff --git a/src/models/user/userRegistration.model.ts b/src/models/user/userRegistration.model.ts index 025a0da..5ddc66b 100644 --- a/src/models/user/userRegistration.model.ts +++ b/src/models/user/userRegistration.model.ts @@ -5,6 +5,7 @@ export interface CreateUserModel { walletAddress?: string; username: string; email: string; + telegramHandle?: string; profilePicture?: string; invitationToken?: string; } @@ -14,6 +15,7 @@ export const createUserScheme = Joi.object({ walletAddress: Joi.string().optional(), username: Joi.string().required(), email: Joi.string().required().email(), + telegramHandle: Joi.string().optional(), profilePicture: Joi.string().uri().optional(), invitationToken: Joi.string().optional() }); diff --git a/src/routers/rounds.router.ts b/src/routers/rounds.router.ts index e3cfa71..5ac898e 100644 --- a/src/routers/rounds.router.ts +++ b/src/routers/rounds.router.ts @@ -19,6 +19,7 @@ export class RoundsRouter { this._router.get('/:roundId', jwtMiddleware, this.roundsController.getRoundById); this._router.post('/assess', jwtMiddleware, this.roundsController.addAssessment); this._router.get('/:roundId/assessments', jwtMiddleware, this.roundsController.getAssessments); + this._router.put('/:roundId/assessments/:assessmentId', jwtMiddleware, this.roundsController.editAssessment); this._router.post('/:roundId/assessments/remind', jwtMiddleware, this.roundsController.remind); this._router.post('/:roundId/txHash', jwtMiddleware, this.roundsController.addTokenMintTx); } diff --git a/src/services/round.service.ts b/src/services/round.service.ts index ac1e978..418e556 100644 --- a/src/services/round.service.ts +++ b/src/services/round.service.ts @@ -441,6 +441,54 @@ export class RoundService { await this.assessmentRepository.save(newAssessment); return ResponseModel.createSuccess({ id: newAssessment.id }); } + + + public async editAssessment(assessmentId: string, walletAddress: string, assessmentData: CreateAssessmentModel): + Promise> { + + const assessor = await this.userRepository.findOne({ + where: { address: walletAddress.toLowerCase() }, + relations: ['organization', 'agreement'] + }); + + if (!assessor) { + return ResponseModel.createError(new Error('Assessor not found'), 404); + } + + const assessment = await this.assessmentRepository.findOne({ + where: { id: assessmentId }, + relations: ['round'] + }); + + if (!assessment) { + return ResponseModel.createError(new Error('Assessment not found'), 404); + } + + const utcNow = new Date(); + const currentRound = await this.roundsRepository.findOne({ + where: { + organization: { id: assessor.organization.id }, + startDate: LessThanOrEqual(utcNow), + endDate: MoreThanOrEqual(utcNow) + } + }); + + if (!currentRound) { + return ResponseModel.createError(new Error('No active round found for the organization'), 400); + } + + if (assessment!.round.id !== currentRound!.id) { + return ResponseModel.createError(new Error('Assessment not in current round'), 400); + } + + assessment.cultureScore = assessmentData.cultureScore; + assessment.workScore = assessmentData.workScore; + assessment.feedbackPositive = assessmentData.feedbackPositive; + assessment.feedbackNegative = assessmentData.feedbackNegative; + + await this.assessmentRepository.save(assessment); + return ResponseModel.createSuccess({ id: assessment.id }); + } public async getAssessments(roundId: string, assessorId: string | null = null, assessedId: string | null = null) : Promise> { diff --git a/src/services/user.service.ts b/src/services/user.service.ts index 9f817d3..2ee4fee 100644 --- a/src/services/user.service.ts +++ b/src/services/user.service.ts @@ -91,6 +91,7 @@ export class UserService { user.address = userData.walletAddress!.toLowerCase(); user.username = userData.username; user.email = userData.email; + user.telegramHandle = userData.telegramHandle; user.profilePicture = userData.profilePicture; user.isAdmin = false; @@ -120,7 +121,7 @@ export class UserService { const contributions = await contributionsRepo.find({ where: { contributor: { id: user.id } } }); let totalFiat = 0; if (contributions.length > 0) { - totalFiat = contributions.reduce((acc, curr) => acc + curr.fiat, 0); + totalFiat = contributions.reduce((acc, curr) => acc + +curr.fiat, 0); } const responseModel: UserResponseModel = { @@ -128,6 +129,7 @@ export class UserService { walletAddress: user.address, username: user.username, email: user.email, + telegramHandle: user.telegramHandle, profilePicture: user.profilePicture, isAdmin: user.isAdmin, totalFiat, From 891bfb789f01741e9e9d0d7c7761066a69dcf1ae Mon Sep 17 00:00:00 2001 From: migrenaa Date: Sun, 2 Mar 2025 13:33:19 +0200 Subject: [PATCH 9/9] removed console.log --- src/services/round.service.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/services/round.service.ts b/src/services/round.service.ts index 2f8557e..7c54a8d 100644 --- a/src/services/round.service.ts +++ b/src/services/round.service.ts @@ -63,7 +63,6 @@ export class RoundService { .getMany(); } for (const org of orgs) { - console.log(`[${new Date()}][createRounds] Creating Round for : ${org.id}`); const startRoundDate = calculateAssessmentRoundStartTime( +org.compensationPeriod!,