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

Conversation

jauggy
Copy link
Member

@jauggy jauggy commented Jun 30, 2024

Work Done

Fixes #334
Also allows filtering by Small Team and Large Team when exporting data

Test Steps

  1. Login website as root@localhost (or whatever is the admin)
  2. Go to Reports > Data Exports > Match Ratings
  3. Press Generate Export. There should be a download with no errors
  4. Change Game type to "Small Team" and generate export. There should be a download with no errors
  5. Change Game type to "Large Team" and generate export. There should be a download with no errors
  6. Repeat with Player Ratings, Ratings Logs, Match Datatable tabs

@jauggy jauggy marked this pull request as ready for review July 1, 2024 11:39
@geekingfrog
Copy link
Contributor

Looks alright to me.
I couldn't test that locally (yet) because there's another error if there is no match at all in the DB.

@jauggy
Copy link
Member Author

jauggy commented Jul 2, 2024

So before this line:

AND rating_type_id = $3

would fetch zero rows when the $3 is nil. And we would get the error as shown in #334

Now, it should not error if you actually have matches. If you don't have any matches at all it would error but that would only occur if you didn't run the mix teiserver.fakedata locally.

@jauggy jauggy marked this pull request as draft July 26, 2024 01:44
@jauggy
Copy link
Member Author

jauggy commented Jul 26, 2024

This no longer passes tests so setting to draft. Also it might not be needed because there may other ways to access the data if we set up data dumps.

Comment on lines +113 to +134
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

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.

Copy link
Collaborator

@L-e-x-o-n L-e-x-o-n left a comment

Choose a reason for hiding this comment

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

Only query changes are needed, the rest has been fixed with team split fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error on exporting Match Ratings (dev environment)
3 participants