From d90ada6c3ef03bf0e2eb714cdb90bb3a4482bd86 Mon Sep 17 00:00:00 2001 From: Lee Peuker Date: Thu, 22 Aug 2024 14:07:04 +0200 Subject: [PATCH] Add location to history export --- src/Domain/Movie/MovieRepository.php | 3 ++- src/Service/Export/ExportService.php | 2 +- src/Service/Export/ExportWriter.php | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Domain/Movie/MovieRepository.php b/src/Domain/Movie/MovieRepository.php index 1ded9d65..9f2b2088 100644 --- a/src/Domain/Movie/MovieRepository.php +++ b/src/Domain/Movie/MovieRepository.php @@ -925,9 +925,10 @@ public function fetchWatchDatesForMovieIds(int $userId, array $movieIds) : array public function fetchWatchDatesOrderedByWatchedAtDesc(int $userId) : array { return $this->dbConnection->fetchAllAssociative( - 'SELECT m.*, muwd.watched_at, muwd.plays, comment + 'SELECT m.*, muwd.watched_at, muwd.plays, comment, l.name as location_name FROM movie_user_watch_dates muwd JOIN movie m on muwd.movie_id = m.id + JOIN location l on muwd.location_id = l.id WHERE muwd.user_id = ? ORDER BY watched_at DESC, muwd.position DESC', [$userId], diff --git a/src/Service/Export/ExportService.php b/src/Service/Export/ExportService.php index c3bc77b6..4206a54c 100644 --- a/src/Service/Export/ExportService.php +++ b/src/Service/Export/ExportService.php @@ -8,7 +8,7 @@ class ExportService { - private const CSV_HEADER_HISTORY = 'title,year,tmdbId,imdbId,watchedAt,comment' . PHP_EOL; + private const CSV_HEADER_HISTORY = 'title,year,tmdbId,imdbId,watchedAt,comment,location' . PHP_EOL; private const CSV_HEADER_RATINGS = 'title,year,tmdbId,imdbId,userRating' . PHP_EOL; diff --git a/src/Service/Export/ExportWriter.php b/src/Service/Export/ExportWriter.php index 91d76e66..2abef65a 100644 --- a/src/Service/Export/ExportWriter.php +++ b/src/Service/Export/ExportWriter.php @@ -51,6 +51,7 @@ public function writeWatchDateToCsv($fileHandle, array $movieWatchDate) : void $movieWatchDate['imdb_id'], $watchDate, $movieWatchDate['comment'], + $movieWatchDate['location_name'], ]); if ($lengthOfWrittenString === false) {