mirror of
https://github.com/fergalmoran/picard.git
synced 2026-02-05 07:14:00 +00:00
PICARD-2481: shorten country long lists in search results
Use limited_join() as we do elsewhere to limit the size of the list to something usable. Add new `countries_shortlist()` to wrap call to `limited_join()`
This commit is contained in:
@@ -39,7 +39,7 @@ from picard.mbjson import (
|
||||
)
|
||||
from picard.metadata import Metadata
|
||||
from picard.util import (
|
||||
limited_join,
|
||||
countries_shortlist,
|
||||
uniqify,
|
||||
)
|
||||
|
||||
@@ -87,7 +87,7 @@ class ReleaseGroup(DataObject):
|
||||
|
||||
countries = countries_from_node(node)
|
||||
if countries:
|
||||
country_label = limited_join(countries, 6, '+', '…')
|
||||
country_label = countries_shortlist(countries)
|
||||
else:
|
||||
country_label = node.get('country', '') or '??'
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ from picard.mbjson import (
|
||||
release_to_metadata,
|
||||
)
|
||||
from picard.metadata import Metadata
|
||||
from picard.util import countries_shortlist
|
||||
from picard.webservice.api_helpers import build_lucene_query
|
||||
|
||||
from picard.ui.searchdialog import (
|
||||
@@ -325,7 +326,7 @@ class AlbumSearchDialog(SearchDialog):
|
||||
release["tracks"] = node['track-count']
|
||||
countries = countries_from_node(node)
|
||||
if countries:
|
||||
release["country"] = ", ".join(countries)
|
||||
release["country"] = countries_shortlist(countries)
|
||||
self.search_results.append(release)
|
||||
|
||||
def display_results(self):
|
||||
|
||||
@@ -37,7 +37,10 @@ from picard.mbjson import (
|
||||
)
|
||||
from picard.metadata import Metadata
|
||||
from picard.track import Track
|
||||
from picard.util import sort_by_similarity
|
||||
from picard.util import (
|
||||
countries_shortlist,
|
||||
sort_by_similarity,
|
||||
)
|
||||
from picard.webservice.api_helpers import build_lucene_query
|
||||
|
||||
from picard.ui.searchdialog import (
|
||||
@@ -161,7 +164,7 @@ class TrackSearchDialog(SearchDialog):
|
||||
release_group_to_metadata(rg_node, track)
|
||||
countries = countries_from_node(rel_node)
|
||||
if countries:
|
||||
track["country"] = ", ".join(countries)
|
||||
track["country"] = countries_shortlist(countries)
|
||||
self.search_results.append((track, node))
|
||||
else:
|
||||
# This handles the case when no release is associated with a track
|
||||
|
||||
@@ -908,6 +908,10 @@ def limited_join(a_list, limit, join_string='+', middle_string='…'):
|
||||
return join_string.join(start + [middle_string] + end)
|
||||
|
||||
|
||||
def countries_shortlist(countries):
|
||||
return limited_join(countries, 6, '+', '…')
|
||||
|
||||
|
||||
def extract_year_from_date(dt):
|
||||
""" Extracts year from passed in date either dict or string """
|
||||
|
||||
|
||||
Reference in New Issue
Block a user