Add routes for daily weekly and the rest

This commit is contained in:
2024-08-09 22:32:58 +02:00
parent 8119775084
commit fce5b8416e
19 changed files with 472 additions and 27 deletions

View File

@@ -1,5 +1,23 @@
export namespace main {
export class AggregatedFood {
period: string;
amount: number;
avgPer100: number;
energy: number;
static createFrom(source: any = {}) {
return new AggregatedFood(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.period = source["period"];
this.amount = source["amount"];
this.avgPer100 = source["avgPer100"];
this.energy = source["energy"];
}
}
export class Food {
rowid: number;
date: string;
@@ -24,6 +42,40 @@ export namespace main {
this.energy = source["energy"];
}
}
export class WailsAggregateFood {
data: AggregatedFood[];
success: boolean;
error?: string;
static createFrom(source: any = {}) {
return new WailsAggregateFood(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.data = this.convertValues(source["data"], AggregatedFood);
this.success = source["success"];
this.error = source["error"];
}
convertValues(a: any, classs: any, asMap: boolean = false): any {
if (!a) {
return a;
}
if (a.slice && a.map) {
return (a as any[]).map(elem => this.convertValues(elem, classs));
} else if ("object" === typeof a) {
if (asMap) {
for (const key of Object.keys(a)) {
a[key] = new classs(a[key]);
}
return a;
}
return new classs(a);
}
return a;
}
}
export class WailsFood {
data: Food[];
success: boolean;
@@ -136,6 +188,7 @@ export namespace main {
weightMonthlyLookback: number;
weightYearlyLookback: number;
target: number;
limit: number;
static createFrom(source: any = {}) {
return new settings(source);
@@ -156,6 +209,7 @@ export namespace main {
this.weightMonthlyLookback = source["weightMonthlyLookback"];
this.weightYearlyLookback = source["weightYearlyLookback"];
this.target = source["target"];
this.limit = source["limit"];
}
}