diff --git a/lib/teiserver/game/exports/match_ratings_export.ex b/lib/teiserver/game/exports/match_ratings_export.ex index 64199dcfb..fd0fa2e56 100644 --- a/lib/teiserver/game/exports/match_ratings_export.ex +++ b/lib/teiserver/game/exports/match_ratings_export.ex @@ -91,21 +91,8 @@ defmodule Teiserver.Game.MatchRatingsExport do # Gets the list of ids but chunks them so we don't try to do too much at once defp calculate_match_pages(start_date, end_date, rating_type_id) do - query = """ - SELECT COUNT(id) - FROM teiserver_battle_matches - WHERE - started >= $1 - AND finished < $2 - AND rating_type_id = $3 - AND processed = true - AND winning_team IS NOT NULL - AND finished IS NOT NULL - AND started IS NOT NULL - """ - match_count = - case Ecto.Adapters.SQL.query(Repo, query, [start_date, end_date, rating_type_id]) do + case get_match_count_query(start_date, end_date, rating_type_id) do {:ok, results} -> results.rows |> List.flatten() |> hd @@ -123,6 +110,28 @@ defmodule Teiserver.Game.MatchRatingsExport do end) end + defp get_match_count_query(start_date, end_date, rating_type_id) do + query = """ + SELECT COUNT(id) + FROM teiserver_battle_matches + WHERE + started >= $1 + AND finished < $2 + AND processed = true + AND winning_team IS NOT NULL + AND finished IS NOT NULL + AND started IS NOT NULL + """ + + if(rating_type_id == nil) do + Ecto.Adapters.SQL.query(Repo, query, [start_date, end_date]) + else + query = query <> " AND rating_type_id = $3" + + Ecto.Adapters.SQL.query(Repo, query, [start_date, end_date, rating_type_id]) + end + end + defp get_match_ids_in_chunk(start_date, end_date, rating_type_id, offset, limit) do query = """ SELECT id diff --git a/lib/teiserver_web/templates/report/exports/match_datatable.html.heex b/lib/teiserver_web/templates/report/exports/match_datatable.html.heex index e8affd28d..d45f46275 100644 --- a/lib/teiserver_web/templates/report/exports/match_datatable.html.heex +++ b/lib/teiserver_web/templates/report/exports/match_datatable.html.heex @@ -44,7 +44,8 @@ [ "All", "Duel", - "Team", + "Small Team", + "Large Team", "FFA", "Team FFA" ], diff --git a/lib/teiserver_web/templates/report/exports/match_ratings.html.heex b/lib/teiserver_web/templates/report/exports/match_ratings.html.heex index f7df80e77..c0c2572a0 100644 --- a/lib/teiserver_web/templates/report/exports/match_ratings.html.heex +++ b/lib/teiserver_web/templates/report/exports/match_ratings.html.heex @@ -44,7 +44,8 @@ [ "All", "Duel", - "Team", + "Small Team", + "Large Team", "FFA", "Team FFA" ], diff --git a/lib/teiserver_web/templates/report/exports/player_ratings.html.heex b/lib/teiserver_web/templates/report/exports/player_ratings.html.heex index faaf19e91..23123597f 100644 --- a/lib/teiserver_web/templates/report/exports/player_ratings.html.heex +++ b/lib/teiserver_web/templates/report/exports/player_ratings.html.heex @@ -44,7 +44,8 @@ [ "All", "Duel", - "Team", + "Small Team", + "Large Team", "FFA", "Team FFA" ], diff --git a/lib/teiserver_web/templates/report/exports/rating_logs.html.heex b/lib/teiserver_web/templates/report/exports/rating_logs.html.heex index 8ce46ab99..df938746d 100644 --- a/lib/teiserver_web/templates/report/exports/rating_logs.html.heex +++ b/lib/teiserver_web/templates/report/exports/rating_logs.html.heex @@ -44,7 +44,8 @@ [ "All", "Duel", - "Team", + "Small Team", + "Large Team", "FFA", "Team FFA" ],