diff --git a/lib/Controller/MetricsController.php b/lib/Controller/MetricsController.php index 40ec199..f668130 100644 --- a/lib/Controller/MetricsController.php +++ b/lib/Controller/MetricsController.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace OCA\RePod\Controller; use OCA\GPodderSync\Core\PodcastData\PodcastDataReader; +use OCA\GPodderSync\Core\PodcastData\PodcastMetrics; use OCA\GPodderSync\Core\PodcastData\PodcastMetricsReader; use OCA\RePod\AppInfo\Application; use OCA\RePod\Service\UserService; @@ -30,14 +31,19 @@ class MetricsController extends Controller #[NoCSRFRequired] #[FrontpageRoute(verb: 'GET', url: '/metrics')] public function index(): JSONResponse { - $subscriptions = $this->podcastMetricsReader->metrics($this->userService->getUserUID()); + $metrics = $this->podcastMetricsReader->metrics($this->userService->getUserUID()); + usort($metrics, fn (PodcastMetrics $a, PodcastMetrics $b) => $b->getListenedSeconds() <=> $a->getListenedSeconds()); + $subscriptions = []; + + foreach ($metrics as $metric) { + $subscription = $metric->toArray(); - foreach ($subscriptions as $id => $subscription) { try { - $subscriptions[$id]['data'] = $this->podcastDataReader->getCachedOrFetchPodcastData($subscription->getUrl(), $this->userService->getUserUID()); + $subscription['data'] = $this->podcastDataReader->getCachedOrFetchPodcastData($metric->getUrl(), $this->userService->getUserUID()); } catch (\Exception $e) { - continue; } + + $subscriptions[] = $subscription; } return new JSONResponse($subscriptions); diff --git a/package.json b/package.json index 3f838b5..b6e8ebc 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,8 @@ "dev": "vite --mode development build", "dev:watch": "vite --mode development build --watch", "watch": "npm run dev:watch", - "lint": "eslint src", - "lint:fix": "eslint src --fix", + "lint": "vue-tsc && eslint src", + "lint:fix": "vue-tsc && eslint src --fix", "stylelint": "stylelint src/**/*.vue src/**/*.scss src/**/*.css", "stylelint:fix": "stylelint src/**/*.vue src/**/*.scss src/**/*.css --fix" }, diff --git a/src/components/Feed/Favorite.vue b/src/components/Feed/Favorite.vue index fa3c5a5..dcad203 100644 --- a/src/components/Feed/Favorite.vue +++ b/src/components/Feed/Favorite.vue @@ -1,15 +1,15 @@