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

[EDA-1778] Making the filters works #195

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

mbertani-eb
Copy link
Contributor

This it's the last PR of the filter logs features:
This feature allows the user to filter the logs of a match by two options

  • By the user action states: valid or invalid
  • By the kind of the actions: in wumpus shoot or move

In this PR I added the filtering itself logic in JavaScript in static/js/filter_logs.js file. Which has the following methods:

  • getLogsFiltered is the main function of filtering. Where the magic happens
  • isNotAll check if the option it's all
  • selectedOption search the current user selection
  • download start the downloading of the file

I was forced to refactor the development/common/match_result_text.py to adapt to this new functionality for the followings reasons:

  1. the logs was been parsed in a more readable text in the generate_text( ) function, but all logs were put it together as one big string, and then the user could download them. To filter the logs I need to could access the logs in an array way. So I decided to change this method to return a list instead string and create another method generate_text_str( ) that returned as a string for certain place that needed in that way.
  2. I refactor the dependencies functions of generate_text() too, to adapt them to return a string instead of receiben the string variable as a buffer and modify inside.
  3. Also I have to refactor something that no were correctly pythonic with PEP8

I add the filters to development/templates/development/new_match_details.html, the new logs template. I wrpas the filter inside a bootstrap collapse

Demo.mov

I think it would be nice to have filter by turn range too in followings iteration. Also adding a switch to could view all the logs the user is filtering. Sometihin similar to the old template used

<select class="form-control" name="valid_move" id="valid_move">
<optgroup label="Validity">
{% for states in move_states %}
{% if states != "gameover" %}

Choose a reason for hiding this comment

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

why is this filtering happening here? shouldn't move_states be pre-filtered with the options we allow first?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're all right. I should have put this inside the possible_states property of the FilterLogs class. I'm changing it

@codeclimate
Copy link

codeclimate bot commented Oct 28, 2022

Code Climate has analyzed commit ea8429c and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (70% is the threshold).

This pull request will bring the total coverage in the repository to 100.0% (0.0% change).

View more on Code Climate.

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.

2 participants