Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions sir/schema/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,24 @@
SearchAnnotation = E(modelext.CustomAnnotation, [
F("id", "id"),
F("entity", ["areas.area.gid", "artists.artist.gid", "events.event.gid",
"instruments.instrument.gid", "labels.label.gid",
"places.place.gid", "recordings.recording.gid",
"releases.release.gid", "release_groups.release_group.gid",
"genres.genre.gid", "instruments.instrument.gid",
"labels.label.gid", "places.place.gid",
"recordings.recording.gid", "releases.release.gid",
"release_groups.release_group.gid",
"series.series.gid", "works.work.gid"]),
F("name", ["areas.area.name", "artists.artist.name", "events.event.name",
"instruments.instrument.name", "labels.label.name",
"places.place.name", "recordings.recording.name",
"releases.release.name", "release_groups.release_group.name",
"genres.genre.name", "instruments.instrument.name",
"labels.label.name", "places.place.name",
"recordings.recording.name", "releases.release.name",
"release_groups.release_group.name",
"series.series.name", "works.work.name"]),
F("text", "text"),
F("type", ["areas.__tablename__", "artists.__tablename__",
"events.__tablename__", "instruments.__tablename__",
"labels.__tablename__", "places.__tablename__",
"recordings.__tablename__", "releases.__tablename__",
"release_groups.__tablename__", "series.__tablename__",
"works.__tablename__"],
"events.__tablename__", "genres.__tablename__",
"instruments.__tablename__", "labels.__tablename__",
"places.__tablename__", "recordings.__tablename__",
"releases.__tablename__", "release_groups.__tablename__",
"series.__tablename__", "works.__tablename__"],
transformfunc=tfs.annotation_type)
],
1.5,
Expand Down
1 change: 1 addition & 0 deletions sir/schema/modelext.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class CustomAnnotation(Annotation):
areas = relationship("AreaAnnotation", viewonly=True)
artists = relationship("ArtistAnnotation", viewonly=True)
events = relationship("EventAnnotation", viewonly=True)
genres = relationship("GenreAnnotation", viewonly=True)
instruments = relationship("InstrumentAnnotation", viewonly=True)
labels = relationship("LabelAnnotation", viewonly=True)
places = relationship("PlaceAnnotation", viewonly=True)
Expand Down
4 changes: 3 additions & 1 deletion sir/schema/queryext.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# Copyright (c) 2015 Wieland Hoffmann
# License: MIT, see LICENSE for details
from mbdata.models import (Annotation, AreaAnnotation, ArtistAnnotation,
EventAnnotation, InstrumentAnnotation, LabelAnnotation,
EventAnnotation, GenreAnnotation,
InstrumentAnnotation, LabelAnnotation,
PlaceAnnotation, RecordingAnnotation, ReleaseAnnotation,
ReleaseGroupAnnotation, SeriesAnnotation, WorkAnnotation)
from sqlalchemy import func
Expand All @@ -13,6 +14,7 @@
AreaAnnotation,
ArtistAnnotation,
EventAnnotation,
GenreAnnotation,
InstrumentAnnotation,
LabelAnnotation,
PlaceAnnotation,
Expand Down
1 change: 1 addition & 0 deletions sir/schema/transformfuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"area_annotation": "area",
"artist_annotation": "artist",
"event_annotation": "event",
"genre_annotation": "genre",
"instrument_annotation": "instrument",
"label_annotation": "label",
"place_annotation": "place",
Expand Down
2 changes: 2 additions & 0 deletions sir/wscompat/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,8 @@ def convert_annotation(obj):
l.append(convert_one_annotation(obj, 'artist', a.artist))
for a in obj.events:
l.append(convert_one_annotation(obj, 'event', a.event))
for a in obj.genres:
l.append(convert_one_annotation(obj, 'genre', a.genre))
for a in obj.instruments:
l.append(convert_one_annotation(obj, 'instrument', a.instrument))
for a in obj.labels:
Expand Down
6 changes: 6 additions & 0 deletions test/sql/annotation.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,19 @@ INSERT INTO artist (id, gid, name, sort_name) VALUES
(5, 'dc19b13a-5ca5-44f5-8f0e-0c37a8ab1958', 'Annotated Artist A', 'Annotated Artist A'),
(6, 'ca4c2228-227c-4904-932a-dff442c091ea', 'Annotated Artist B', 'Annotated Artist B');

INSERT INTO genre (id, gid, name) VALUES
(1, '1b50083b-1afa-4778-82c8-548b309af783', 'dubstep');

UPDATE artist_meta SET rating=70, rating_count=4 WHERE id=3;

INSERT INTO annotation (id, editor, text) VALUES (1, 1, 'Test annotation 1');
INSERT INTO annotation (id, editor, text) VALUES (2, 1, 'Test annotation 2');
INSERT INTO annotation (id, editor, text) VALUES (3, 1, 'Duplicate annotation');
INSERT INTO annotation (id, editor, text) VALUES (4, 1, 'Duplicate annotation');
INSERT INTO annotation (id, editor, text) VALUES (5, 1, 'Genre annotation');

INSERT INTO artist_annotation (artist, annotation) VALUES (3, 1), (4, 2), (5, 3), (6, 4);

INSERT INTO genre_annotation (genre, annotation) VALUES (1, 5);

INSERT INTO artist_gid_redirect VALUES ('a4ef1d08-962e-4dd6-ae14-e42a6a97fc11', 3);
8 changes: 8 additions & 0 deletions test/test_indexing_real_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,14 @@ def test_index_cdstub(self):

def test_index_annotation(self):
expected = [
{
'_store': '<ns0:annotation xmlns:ns0="http://musicbrainz.org/ns/mmd-2.0#" type="genre"><ns0:entity>1b50083b-1afa-4778-82c8-548b309af783</ns0:entity><ns0:name>dubstep</ns0:name><ns0:text>Genre annotation</ns0:text></ns0:annotation>',
'name': u'dubstep',
'text': u'Genre annotation',
'entity': '1b50083b-1afa-4778-82c8-548b309af783',
'type': 'genre',
'id': 1
},
{
'_store': '<ns0:annotation xmlns:ns0="http://musicbrainz.org/ns/mmd-2.0#" type="artist"><ns0:entity>745c079d-374e-4436-9448-da92dedef3ce</ns0:entity><ns0:name>Test Artist</ns0:name><ns0:text>Test annotation 1</ns0:text></ns0:annotation>',
'name': u'Test Artist',
Expand Down
Loading