Skip to content

Commit

Permalink
add cluster matching sync timestamp and logs (#1913)
Browse files Browse the repository at this point in the history
* add cluster matching sync timestamp and logs

* add nullability to clustermathicng syncAT
  • Loading branch information
CarlosQ96 authored Jan 22, 2025
1 parent 9bcaded commit 7e9c1b6
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
25 changes: 25 additions & 0 deletions migration/1737544105947-addClusterMatchingSyncAtTimestamp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm';

export class addClusterMatchingSyncAtTimestamp1737544105947
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
const table = await queryRunner.getTable('qf_round');
const columnExists = table?.findColumnByName('clusterMatchingSyncAt');

if (!columnExists) {
await queryRunner.addColumn(
'qf_round',
new TableColumn({
name: 'clusterMatchingSyncAt',
type: 'timestamp',
isNullable: true,
}),
);
}
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropColumn('qf_round', 'clusterMatchingSyncAt');
}
}
4 changes: 4 additions & 0 deletions src/entities/qfRound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ export class QfRound extends BaseEntity {
@Column({ default: false })
isDataAnalysisDone: boolean;

@Field(_type => Date, { nullable: true })
@Column({ nullable: true })
clusterMatchingSyncAt?: Date;

@UpdateDateColumn()
updatedAt: Date;

Expand Down
4 changes: 4 additions & 0 deletions src/services/cronJobs/syncEstimatedClusterMatchingJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ export const fetchAndUpdateClusterEstimatedMatching = async () => {
activeQfRound.id,
matchingData,
);

// Update latest job ran succesfully
activeQfRound.clusterMatchingSyncAt = new Date();
await activeQfRound.save();
} catch (e) {
logger.error('fetchAndUpdateClusterEstimatedMatching error', e);
} finally {
Expand Down
12 changes: 10 additions & 2 deletions src/workers/cocm/estimatedClusterMatchingWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,20 @@ export type EstimatedClusterMatchingWorker =

const worker: EstimatedClusterMatchingWorker = {
async fetchEstimatedClusterMatching(matchingDataInput: any) {
return await getClusterMatchingAdapter().fetchEstimatedClusterMatchings(
matchingDataInput,
logger.debug('fetchEstimatedClusterMatching() has been called');
const matchingData =
await getClusterMatchingAdapter().fetchEstimatedClusterMatchings(
matchingDataInput,
);
logger.debug(
'fetchEstimatedClusterMatching() has worked with params',
String(matchingData),
);
return matchingData;
},

async updateEstimatedClusterMatching(qfRoundId: number, matchingData: any) {
logger.debug('updateEstimatedClusterMatching() has been called');
try {
const params: any[] = [];
const values = matchingData
Expand Down

0 comments on commit 7e9c1b6

Please sign in to comment.