Skip to content

Commit 9cb1877

Browse files
committed
SEARCH-666: Use quality names rather than numeric IDs
This matches what we do elsewhere in the API, matches what was listed in our documentation, and removes the split between -1 (default) and 1 (normal) which we don't generally expose to data users.
1 parent dc96c30 commit 9cb1877

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

sir/schema/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@
399399
F("mediums", "medium_count", transformfunc=tfs.integer_sum, trigger=False),
400400
F("packaging", "packaging.name"),
401401
F("primarytype", "release_group.type.name"),
402-
F("quality", "quality"),
402+
F("quality", "quality", transformfunc=tfs.quality_to_string),
403403
F("rgid", "release_group.gid"),
404404
F("script", "script.iso_code"),
405405
F("secondarytype", "release_group.secondary_types.secondary_type.name"),

sir/schema/transformfuncs.py

+12
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,18 @@ def boolean(values):
101101
else:
102102
return "f"
103103

104+
def quality_to_string(values):
105+
"""
106+
:type values: set
107+
"""
108+
quality = values.pop()
109+
if quality == 0:
110+
return "low"
111+
elif quality == 2:
112+
return "high"
113+
else:
114+
# Both 1 (normal, hand-set) and -1 (default) should return "normal"
115+
return "normal"
104116

105117
def url_type(values):
106118
types = set(URL_LINK_TABLE_TO_ENTITYTYPE[value] for value in values)

test/sql/release.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ INSERT INTO track (id, gid, name, artist_credit, medium, position, number, recor
5353

5454
INSERT INTO release_group (id, gid, name, artist_credit)
5555
VALUES (4, '329fb554-2a81-3d8a-8e22-ec2c66810019', 'Blonde on Blonde', 2);
56-
INSERT INTO release (id, gid, name, artist_credit, release_group) VALUES (5, '538aff00-a009-4515-a064-11a6d5a502ee', 'Blonde on Blonde', 2, 4);
56+
INSERT INTO release (id, gid, name, artist_credit, release_group, quality) VALUES (5, '538aff00-a009-4515-a064-11a6d5a502ee', 'Blonde on Blonde', 2, 4, 0);
5757
;
5858

5959
-- release_meta

test/test_indexing_real_data.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ def test_index_release(self):
402402
'mbid': '7a906020-72db-11de-8a39-0800200c9a66',
403403
'rgid': '3b4faa80-72d9-11de-8a39-0800200c9a66',
404404
'release': u'Release #2',
405-
'quality': -1
405+
'quality': u'normal'
406406
},
407407
{
408408
'comment': u'Comment',
@@ -424,7 +424,7 @@ def test_index_release(self):
424424
'rgid': '3b4faa80-72d9-11de-8a39-0800200c9a66',
425425
'laid': '00a23bd0-72db-11de-8a39-0800200c9a66',
426426
'release': u'Arrival',
427-
'quality': -1,
427+
'quality': u'normal',
428428
'primarytype': u'Album'
429429
},
430430
{
@@ -436,7 +436,7 @@ def test_index_release(self):
436436
'mbid': '538aff00-a009-4515-a064-11a6d5a502ee',
437437
'rgid': '329fb554-2a81-3d8a-8e22-ec2c66810019',
438438
'release': u'Blonde on Blonde',
439-
'quality': -1},
439+
'quality': u'low'},
440440
{
441441
'_store': '<ns0:release xmlns:ns0="http://musicbrainz.org/ns/mmd-2.0#" id="25b6fe30-ff5b-11de-8a39-0800200c9a66"><ns0:title>Various Release</ns0:title><ns0:artist-credit><ns0:name-credit><ns0:name>Various Artists</ns0:name><ns0:artist id="7a906020-72db-11de-8a39-0800200c9a66"><ns0:name>Various Artists</ns0:name><ns0:sort-name>Various Artists</ns0:sort-name></ns0:artist></ns0:name-credit></ns0:artist-credit><ns0:release-group id="25b6fe30-ff5b-11de-8a39-0800200c9a66"><ns0:title>Various Release</ns0:title></ns0:release-group><ns0:medium-list count="1"><ns0:track-count>3</ns0:track-count><ns0:medium><ns0:disc-list count="0" /><ns0:track-list count="3" /></ns0:medium></ns0:medium-list><ns0:tag-list /></ns0:release>',
442442
'tracks': 3, 'artist': u'Various Artists',
@@ -448,7 +448,7 @@ def test_index_release(self):
448448
'rgid': '25b6fe30-ff5b-11de-8a39-0800200c9a66',
449449
'release': u'Various Release',
450450
'mediums': 1,
451-
'quality': -1
451+
'quality': u'normal'
452452
}
453453
]
454454
self._test_index_entity("release", expected)

0 commit comments

Comments
 (0)