Fixing monitors to have proper createdAt

This commit is contained in:
Collin Duncan 2025-02-12 14:18:26 +01:00
parent 9e9b0194da
commit 25fb2c9bdc
No known key found for this signature in database
2 changed files with 2 additions and 2 deletions

View file

@ -19,7 +19,6 @@ export class Monitor {
@Column('datetime', { @Column('datetime', {
nullable: false, nullable: false,
default: dayjs(),
transformer: { transformer: {
to: (value?: Dayjs) => (value ?? dayjs()).format(), to: (value?: Dayjs) => (value ?? dayjs()).format(),
from: (value: Date) => dayjs(value), from: (value: Date) => dayjs(value),

View file

@ -2,6 +2,7 @@ import { Injectable } from '@nestjs/common'
import { InjectRepository } from '@nestjs/typeorm' import { InjectRepository } from '@nestjs/typeorm'
import { Repository } from 'typeorm' import { Repository } from 'typeorm'
import dayjsTz from '../common/dayjs'
import { Monitor, MonitorType } from './entity' import { Monitor, MonitorType } from './entity'
@Injectable() @Injectable()
@ -13,7 +14,7 @@ export class MonitorsService {
async performMonitor(type: MonitorType, data: string) { async performMonitor(type: MonitorType, data: string) {
await this.monitorsRepository.save( await this.monitorsRepository.save(
this.monitorsRepository.create({ type, data }), this.monitorsRepository.create({ type, data, createdAt: dayjsTz() }),
) )
} }
} }