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

CB-84: Add checkbox to filter releases with reviews on artist discography pages. #153

Closed
wants to merge 4 commits into from

Conversation

ferbncode
Copy link
Member

@ferbncode ferbncode commented Aug 22, 2017

Added checkbox on artist discography pages to filter only those releases (on that page) which have reviews.

To fetch only those releases which have a review (rather than filtering on that page), I guess we can later fetch all releases (rather than applying the limit) and then show them (shouldn't slow down the page).

@ferbncode
Copy link
Member Author

ferbncode commented Aug 22, 2017

Some screenshots:
Unchecked:
Unchecked
Checked for showing only reviewed entities:
Checked for showing only reviewed entities
No reviewed entities found:
No reviewed releases

<div class="col-sm-4">
<div>
<input type="checkbox" name="only-reviewed" value="1" class="only-reviewed" onchange="showOnlyReviewed()"/>
{{ _('Filter releases here with reviews') }}<br/>
Copy link
Collaborator

Choose a reason for hiding this comment

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

"Only show releases with reviews"

@@ -66,13 +76,16 @@
<a href="{{ url_for('artist.entity', mbid=artist.id) }}?release_type=other">{{ _('Other releases') }}</a>
</li>
</ul>
<div class="no_reviewed_entities">
Copy link
Collaborator

Choose a reason for hiding this comment

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

if the default is to not check the box, can you make this hidden by default instead of hiding it in js?

</div>
<div class="col-sm-4">
<div>
<input type="checkbox" name="only-reviewed" value="1" class="only-reviewed" onchange="showOnlyReviewed()"/>
Copy link
Collaborator

Choose a reason for hiding this comment

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

instead of using an html attribute here, other places in the CB code us jquery to install an event handler:


We should do the same thing for consistency

{% block scripts %}
{{ super() }}
<script>
$(".no_reviewed_entities").hide();
Copy link
Collaborator

Choose a reason for hiding this comment

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

With javascript it's a good idea to run commands only after the full page has loaded. You can use document.ready here:

Copy link
Collaborator

@alastair alastair left a comment

Choose a reason for hiding this comment

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

👍 OK by me, pending feedback from @gentlecat

<div class="col-sm-4">
<div>
<input type="checkbox" name="only-reviewed" value="1" id="only-reviewed"/>
{{ _('Only show releases with reviews') }}<br/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Artist page doesn't have releases. Only release groups.

}
})
})
</script>
Copy link
Contributor

Choose a reason for hiding this comment

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

It's better to put this JS code into a separate script in static/scripts, build and import it.

@gentlecat
Copy link
Contributor

Also please don't forget to assign yourself to the issue in JIRA and mark it as WIP so that there's no confusion if someone else decides to work on it.

@gentlecat
Copy link
Contributor

On the last screenshot there's a "Next" button. Is that a bug or the screenshot is just a prototype?

@ferbncode
Copy link
Member Author

ferbncode commented Sep 2, 2017

On the last screenshot there's a "Next" button. Is that a bug or the screenshot is just a prototype?

The "Next" Button appeared as the filtering was being done on just that page. So, as there were no more reviewed entities (on that page), the "Next Button" appeared. I've fixed this and now all reviewed release groups are shown together.

I've rebased the present branch and based it on PR #140. I've modified the code to fix the problem by fetching all release groups of an artist by directly using the db.
Now all reviewed release groups are shown once the filter is checked. Also, the Previous and the Next buttons don't reload the entire page, but they just refresh the entities to be shown.

@gentlecat
Copy link
Contributor

Was trying to test this and ran into the following issue:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/werkzeug/wsgi.py", line 660, in __call__
    return app(environ, start_response)
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1997, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1985, in wsgi_app
    response = self.handle_exception(e)
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1540, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/code/critiquebrainz/frontend/views/release_group.py", line 28, in entity
    release = mb_release.get_release_by_id(release_group['release-list'][0]['id'])
  File "/code/critiquebrainz/frontend/external/musicbrainz_db/release.py", line 23, in get_release_by_id
    release = _get_release_by_id(mbid)
  File "/code/critiquebrainz/frontend/external/musicbrainz_db/release.py", line 31, in _get_release_by_id
    includes=['media', 'release-groups'],
  File "/code/critiquebrainz/frontend/external/musicbrainz_db/release.py", line 82, in fetch_multiple_releases
    releases = {str(mbid): to_dict_releases(releases[mbid], includes_data[releases[mbid].id]) for mbid in mbids}
  File "/code/critiquebrainz/frontend/external/musicbrainz_db/release.py", line 82, in <dictcomp>
    releases = {str(mbid): to_dict_releases(releases[mbid], includes_data[releases[mbid].id]) for mbid in mbids}
  File "/code/critiquebrainz/frontend/external/musicbrainz_db/serialize.py", line 193, in to_dict_releases
    for medium in includes['media']]
  File "/code/critiquebrainz/frontend/external/musicbrainz_db/serialize.py", line 193, in <listcomp>
    for medium in includes['media']]
  File "/code/critiquebrainz/frontend/external/musicbrainz_db/serialize.py", line 153, in to_dict_medium
    'format': medium.format.name,
AttributeError: 'NoneType' object has no attribute 'name'

@gentlecat
Copy link
Contributor

I'm seeing this on master as well.

Copy link
Contributor

@gentlecat gentlecat left a comment

Choose a reason for hiding this comment

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

The main problem here is that you removed pagination from the release group retrieval. Even if most artists don't have many, some pages will probably be slowed down significantly the more release groups they have.

If this is not the case, I'd like to at least see some proof.

@ferbncode
Copy link
Member Author

ferbncode commented Sep 3, 2017

Even if most artists don't have many, some pages will probably be slowed down significantly the more release groups they have.

That is correct. Some pages slow down as they have many release groups (Various Artists page (no. of release groups: 145133), for instance). But fetching all release groups is important if all reviewed release groups are to be shown together. Some possible (though probably not the best) work-arounds on frontend can be:

  • adding a loader for making the user wait for the page for load.
  • keeping pagination and filtering the reviewed entities only on that very page.

I am unsure if either is a good choice. Please suggest. Thanks!

@paramsingh
Copy link
Collaborator

@ferbncode, I'd like to discuss how exactly to move forward on this, once you get the time.

@paramsingh
Copy link
Collaborator

@paramsingh paramsingh closed this Feb 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants