mirror of
https://github.com/apricote/Listory.git
synced 2026-02-07 18:27:03 +00:00
feat(api): update existing artists in MusicLibrary
This commit is contained in:
parent
a0c28e2324
commit
a0ffe108e1
11 changed files with 176 additions and 1 deletions
|
|
@ -12,6 +12,7 @@ import { FindAlbumDto } from "./dto/find-album.dto";
|
|||
import { FindArtistDto } from "./dto/find-artist.dto";
|
||||
import { FindGenreDto } from "./dto/find-genre.dto";
|
||||
import { FindTrackDto } from "./dto/find-track.dto";
|
||||
import { UpdateArtistDto } from "./dto/update-artist.dto";
|
||||
import { Genre } from "./genre.entity";
|
||||
import { GenreRepository } from "./genre.repository";
|
||||
import { Track } from "./track.entity";
|
||||
|
|
@ -32,6 +33,17 @@ export class MusicLibraryService {
|
|||
});
|
||||
}
|
||||
|
||||
async getArtistWithOldestUpdate(): Promise<Artist | undefined> {
|
||||
const [oldestArtist] = await this.artistRepository.find({
|
||||
take: 1,
|
||||
order: {
|
||||
updatedAt: "ASC",
|
||||
},
|
||||
});
|
||||
|
||||
return oldestArtist;
|
||||
}
|
||||
|
||||
async createArtist(data: CreateArtistDto): Promise<Artist> {
|
||||
const artist = this.artistRepository.create();
|
||||
|
||||
|
|
@ -57,6 +69,17 @@ export class MusicLibraryService {
|
|||
return artist;
|
||||
}
|
||||
|
||||
async updateArtist({
|
||||
artist,
|
||||
updatedFields,
|
||||
}: UpdateArtistDto): Promise<Artist> {
|
||||
artist.name = updatedFields.name;
|
||||
artist.genres = updatedFields.genres;
|
||||
artist.updatedAt = new Date();
|
||||
|
||||
return this.artistRepository.save(artist);
|
||||
}
|
||||
|
||||
async findAlbum(query: FindAlbumDto): Promise<Album | undefined> {
|
||||
return this.albumRepository.findOne({
|
||||
where: { spotify: { id: query.spotify.id } },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue