fix: improve top-artists response time

By calculating the necessary counts in the database, we avoid
unncessary joins and data transmissions.
This commit is contained in:
Julian Tölle 2020-07-11 19:35:31 +02:00
parent 2ea7366a58
commit aecc82576a
4 changed files with 44 additions and 39 deletions

View file

@ -1,5 +1,5 @@
import { Entity, PrimaryGeneratedColumn, Column, ManyToMany } from "typeorm";
import { SpotifyLibraryDetails } from "src/sources/spotify/spotify-library-details.entity";
import { Column, Entity, ManyToMany, PrimaryGeneratedColumn } from "typeorm";
import { Album } from "./album.entity";
@Entity()
@ -11,7 +11,7 @@ export class Artist {
name: string;
@ManyToMany((type) => Album, (album) => album.artists)
albums: Album[];
albums?: Album[];
@Column((type) => SpotifyLibraryDetails)
spotify: SpotifyLibraryDetails;