Refactor AqiSpaceDailyPollutantStatsEntity: update unique constraint and rename event fields for clarity

This commit is contained in:
faris Aljohari
2025-06-04 15:24:13 -06:00
parent ef2245eae1
commit 0d6de2df43

View File

@ -4,7 +4,7 @@ import { SpaceEntity } from '../../space/entities/space.entity';
import { AqiSpaceDailyPollutantStatsDto } from '../dtos';
@Entity({ name: 'space-daily-pollutant-stats' })
@Unique(['spaceUuid', 'eventDay', 'eventHour'])
@Unique(['spaceUuid', 'eventDate'])
export class AqiSpaceDailyPollutantStatsEntity extends AbstractEntity<AqiSpaceDailyPollutantStatsDto> {
@Column({ nullable: false })
public spaceUuid: string;
@ -12,74 +12,170 @@ export class AqiSpaceDailyPollutantStatsEntity extends AbstractEntity<AqiSpaceDa
@ManyToOne(() => SpaceEntity, (space) => space.presenceSensorDaily)
space: SpaceEntity;
@Column({ nullable: false })
public eventDay: string;
@Column({ nullable: false })
public eventHour: number;
@Column({ type: 'date', nullable: false })
public eventDate: Date;
@Column('float', { nullable: true })
public pm1Min: number;
public goodAqiPercentage: number;
@Column('float', { nullable: true })
public pm1Avg: number;
public moderateAqiPercentage: number;
@Column('float', { nullable: true })
public pm1Max: number;
public unhealthySensitiveAqiPercentage: number;
@Column('float', { nullable: true })
public pm10Min: number;
public unhealthyAqiPercentage: number;
@Column('float', { nullable: true })
public pm10Avg: number;
public veryUnhealthyAqiPercentage: number;
@Column('float', { nullable: true })
public pm10Max: number;
public hazardousAqiPercentage: number;
@Column('float', { nullable: true })
public pm25Min: number;
public dailyAvgAqi: number;
@Column('float', { nullable: true })
public pm25Avg: number;
public dailyMaxAqi: number;
@Column('float', { nullable: true })
public pm25Max: number;
public dailyMinAqi: number;
@Column('float', { nullable: true })
public ch2oMin: number;
public goodPm25Percentage: number;
@Column('float', { nullable: true })
public ch2oAvg: number;
public moderatePm25Percentage: number;
@Column('float', { nullable: true })
public ch2oMax: number;
public unhealthySensitivePm25Percentage: number;
@Column('float', { nullable: true })
public vocMin: number;
public unhealthyPm25Percentage: number;
@Column('float', { nullable: true })
public vocAvg: number;
public veryUnhealthyPm25Percentage: number;
@Column('float', { nullable: true })
public vocMax: number;
public hazardousPm25Percentage: number;
@Column('float', { nullable: true })
public co2Min: number;
public dailyAvgPm25: number;
@Column('float', { nullable: true })
public co2Avg: number;
public dailyMaxPm25: number;
@Column('float', { nullable: true })
public co2Max: number;
public dailyMinPm25: number;
@Column('float', { nullable: true })
public aqiMin: number;
public goodPm10Percentage: number;
@Column('float', { nullable: true })
public aqiAvg: number;
public moderatePm10Percentage: number;
@Column('float', { nullable: true })
public aqiMax: number;
public unhealthySensitivePm10Percentage: number;
@Column('float', { nullable: true })
public unhealthyPm10Percentage: number;
@Column('float', { nullable: true })
public veryUnhealthyPm10Percentage: number;
@Column('float', { nullable: true })
public hazardousPm10Percentage: number;
@Column('float', { nullable: true })
public dailyAvgPm10: number;
@Column('float', { nullable: true })
public dailyMaxPm10: number;
@Column('float', { nullable: true })
public dailyMinPm10: number;
@Column('float', { nullable: true })
public goodVocPercentage: number;
@Column('float', { nullable: true })
public moderateVocPercentage: number;
@Column('float', { nullable: true })
public unhealthySensitiveVocPercentage: number;
@Column('float', { nullable: true })
public unhealthyVocPercentage: number;
@Column('float', { nullable: true })
public veryUnhealthyVocPercentage: number;
@Column('float', { nullable: true })
public hazardousVocPercentage: number;
@Column('float', { nullable: true })
public dailyAvgVoc: number;
@Column('float', { nullable: true })
public dailyMaxVoc: number;
@Column('float', { nullable: true })
public dailyMinVoc: number;
@Column('float', { nullable: true })
public goodCo2Percentage: number;
@Column('float', { nullable: true })
public moderateCo2Percentage: number;
@Column('float', { nullable: true })
public unhealthySensitiveCo2Percentage: number;
@Column('float', { nullable: true })
public unhealthyCo2Percentage: number;
@Column('float', { nullable: true })
public veryUnhealthyCo2Percentage: number;
@Column('float', { nullable: true })
public hazardousCo2Percentage: number;
@Column('float', { nullable: true })
public dailyAvgCo2: number;
@Column('float', { nullable: true })
public dailyMaxCo2: number;
@Column('float', { nullable: true })
public dailyMinCo2: number;
@Column('float', { nullable: true })
public goodCh2oPercentage: number;
@Column('float', { nullable: true })
public moderateCh2oPercentage: number;
@Column('float', { nullable: true })
public unhealthySensitiveCh2oPercentage: number;
@Column('float', { nullable: true })
public unhealthyCh2oPercentage: number;
@Column('float', { nullable: true })
public veryUnhealthyCh2oPercentage: number;
@Column('float', { nullable: true })
public hazardousCh2oPercentage: number;
@Column('float', { nullable: true })
public dailyAvgCh2o: number;
@Column('float', { nullable: true })
public dailyMaxCh2o: number;
@Column('float', { nullable: true })
public dailyMinCh2o: number;
constructor(partial: Partial<AqiSpaceDailyPollutantStatsEntity>) {
super();