71 lines
2.6 KiB
TypeScript
71 lines
2.6 KiB
TypeScript
import { Entity, Column, ManyToOne, JoinColumn } from 'typeorm';
|
|
import { ApiProperty } from '@nestjs/swagger';
|
|
import { BaseEntity } from './base.entity';
|
|
import { User } from './user.entity';
|
|
|
|
@Entity({ name: 'sustainability_tracking', schema: 'analytics' })
|
|
export class SustainabilityTracking extends BaseEntity {
|
|
@ApiProperty({ description: 'User ID' })
|
|
@Column({ name: 'user_id' })
|
|
userId: string;
|
|
|
|
@ApiProperty({ description: 'Activity type that generated carbon footprint' })
|
|
@Column({ name: 'activity_type', length: 50 })
|
|
activityType: string; // transportation, accommodation, dining, activities
|
|
|
|
@ApiProperty({ description: 'Activity details' })
|
|
@Column({ name: 'activity_details', type: 'jsonb' })
|
|
activityDetails: {
|
|
description: string;
|
|
location?: string;
|
|
duration?: number;
|
|
distance?: number;
|
|
participants?: number;
|
|
provider?: string;
|
|
};
|
|
|
|
@ApiProperty({ description: 'Carbon footprint in kg CO2' })
|
|
@Column({ name: 'carbon_footprint_kg', type: 'decimal', precision: 10, scale: 3 })
|
|
carbonFootprintKg: number;
|
|
|
|
@ApiProperty({ description: 'Water usage in liters' })
|
|
@Column({ name: 'water_usage_liters', type: 'decimal', precision: 10, scale: 2, nullable: true })
|
|
waterUsageLiters: number;
|
|
|
|
@ApiProperty({ description: 'Waste generated in kg' })
|
|
@Column({ name: 'waste_generated_kg', type: 'decimal', precision: 8, scale: 3, nullable: true })
|
|
wasteGeneratedKg: number;
|
|
|
|
@ApiProperty({ description: 'Energy consumption in kWh' })
|
|
@Column({ name: 'energy_consumption_kwh', type: 'decimal', precision: 10, scale: 3, nullable: true })
|
|
energyConsumptionKwh: number;
|
|
|
|
@ApiProperty({ description: 'Sustainability score (0-100)' })
|
|
@Column({ name: 'sustainability_score', type: 'decimal', precision: 5, scale: 2 })
|
|
sustainabilityScore: number;
|
|
|
|
@ApiProperty({ description: 'Offset credits purchased' })
|
|
@Column({ name: 'offset_credits_kg', type: 'decimal', precision: 10, scale: 3, default: 0 })
|
|
offsetCreditsKg: number;
|
|
|
|
@ApiProperty({ description: 'Cost of offset in USD' })
|
|
@Column({ name: 'offset_cost_usd', type: 'decimal', precision: 8, scale: 2, default: 0 })
|
|
offsetCostUsd: number;
|
|
|
|
@ApiProperty({ description: 'Certification or verification data' })
|
|
@Column({ name: 'certifications', type: 'jsonb', nullable: true })
|
|
certifications: {
|
|
ecoFriendly: boolean;
|
|
carbonNeutral: boolean;
|
|
sustainableTourism: boolean;
|
|
localCommunitySupport: boolean;
|
|
wildlifeProtection: boolean;
|
|
certificationBodies: string[];
|
|
};
|
|
|
|
// Relations
|
|
@ManyToOne(() => User)
|
|
@JoinColumn({ name: 'user_id' })
|
|
user: User;
|
|
}
|