Skip to content

Commit

Permalink
fix: empty responses
Browse files Browse the repository at this point in the history
  • Loading branch information
davidvanleeuwen authored and wietsehage committed Feb 26, 2024
1 parent 91d55a5 commit 9c60aed
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions server/lib/mave_metrics/api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ defmodule MaveMetrics.API do
|> select([v], v.id)
|> Repo.all()

query_aggregated_video_metrics(video_ids, timeframe, minimum_watch_seconds, interval)
if video_ids == [] do
[]
else
query_aggregated_video_metrics(video_ids, timeframe, minimum_watch_seconds, interval)
end
end

def get_sources(%{"video" => query}, interval, timeframe, minimum_watch_seconds) do
Expand All @@ -37,7 +41,11 @@ defmodule MaveMetrics.API do
|> select([v], v.id)
|> Repo.one()

query_individual_video_by_url(video_id, timeframe, minimum_watch_seconds, interval)
if video_id == nil do
[]
else
query_individual_video_by_url(video_id, timeframe, minimum_watch_seconds, interval)
end
end

def query_aggregated_video_metrics(video_ids, timeframe, min_watched_seconds, interval) do
Expand Down

0 comments on commit 9c60aed

Please sign in to comment.