Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix data export #344

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 23 additions & 14 deletions lib/teiserver/game/exports/match_ratings_export.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Comment on lines +113 to +134
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only this change is needed now. The rest has been fixed with team split fixes.

defp get_match_ids_in_chunk(start_date, end_date, rating_type_id, offset, limit) do
query = """
SELECT id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
[
"All",
"Duel",
"Team",
"Small Team",
"Large Team",
"FFA",
"Team FFA"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
[
"All",
"Duel",
"Team",
"Small Team",
"Large Team",
"FFA",
"Team FFA"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
[
"All",
"Duel",
"Team",
"Small Team",
"Large Team",
"FFA",
"Team FFA"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
[
"All",
"Duel",
"Team",
"Small Team",
"Large Team",
"FFA",
"Team FFA"
],
Expand Down
Loading