|
|
|
|
@@ -37,6 +37,9 @@ export class LayerDetailComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
LayerType = LayerType;
|
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
|
shortRecords: any = null;
|
|
|
|
|
|
|
|
|
|
@ViewChild(MatSort) sort!: MatSort;
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
|
@@ -59,6 +62,8 @@ export class LayerDetailComponent implements OnInit {
|
|
|
|
|
this.document.modified = `${this.datePipe.transform(this.document.modifiedAt?.toDate(), 'short')}, ${this.document.modifiedBy?.userName}`;
|
|
|
|
|
this.valueSum = this.document.records.map(t => t.value1 || 0).reduce((acc, value) => acc + value, 0);
|
|
|
|
|
this.createColumns();
|
|
|
|
|
|
|
|
|
|
this.prepareDataForAI();
|
|
|
|
|
}
|
|
|
|
|
private async load(): Promise<Layer> {
|
|
|
|
|
return await Layer.getById(this.route$.snapshot.paramMap.get('id') || "", this.http$);
|
|
|
|
|
@@ -105,4 +110,45 @@ export class LayerDetailComponent implements OnInit {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async prepareDataForAI() {
|
|
|
|
|
const codes = this.document.records.map(x => x.code);
|
|
|
|
|
const weatherURL = 'https://archive-api.open-meteo.com/v1/archive?latitude=54.36685&longitude=18.692&start_date=2023-12-01&end_date=2023-12-31&daily=temperature_2m_mean,rain_sum,snowfall_sum,wind_speed_10m_max&timezone=Europe%2FBerlin';
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
|
this.http$.get(weatherURL).subscribe((data: any) => {
|
|
|
|
|
console.log('pogoda', data);
|
|
|
|
|
|
|
|
|
|
// loop throught all days in december 2023
|
|
|
|
|
const days = data['daily']['time'].length;
|
|
|
|
|
console.log(days);
|
|
|
|
|
this.shortRecords = [];
|
|
|
|
|
for (let i = 0; i < days; i++) {
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
|
const res: any = {};
|
|
|
|
|
res.day = i+1;
|
|
|
|
|
res.code = 600;
|
|
|
|
|
res.temperature = data['daily']['temperature_2m_mean'][i];
|
|
|
|
|
res.rain = data['daily']['rain_sum'][i];
|
|
|
|
|
res.snow = data['daily']['snowfall_sum'][i];
|
|
|
|
|
res.wind = data['daily']['wind_speed_10m_max'][i];
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
|
const codeValues: any[] = [];
|
|
|
|
|
codes.forEach(code => {
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
|
const res: any = { code: code };
|
|
|
|
|
res.value = this.getRecordValue(this.document.records.find(x => x.code === code)!, i+1);
|
|
|
|
|
codeValues.push(res);
|
|
|
|
|
});
|
|
|
|
|
res.sell = codeValues.filter(x => x.value > 0);
|
|
|
|
|
//= codes.map(code => this.getRecordValue(this.document.records.find(x => x.code === code)!, i+1));
|
|
|
|
|
this.shortRecords.push(res);
|
|
|
|
|
}
|
|
|
|
|
console.log('shortRecords', this.shortRecords);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getRecordValue(record: Record, index: number) {
|
|
|
|
|
const propertyName = `value${index}` as keyof typeof record;
|
|
|
|
|
return record[propertyName];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|