added db query optimizations to playlists view, added caching
This commit is contained in:
@@ -91,6 +91,38 @@ export namespace playlist {
|
||||
this.Duration = source["Duration"];
|
||||
}
|
||||
}
|
||||
export class WithTracks {
|
||||
Summary: Summary;
|
||||
Tracks: Track[];
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new WithTracks(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.Summary = this.convertValues(source["Summary"], Summary);
|
||||
this.Tracks = this.convertValues(source["Tracks"], Track);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user