# Copyright (c) 2014 Wieland Hoffmann
# License: MIT, see LICENSE for details
from mbdata import models
from . import modelext
from .searchentities import SearchEntity as E, SearchField as F


SearchRecording = E(modelext.CustomRecording, [
    F("mbid", "gid"),
    F("recording", "name"),
    F("arid", "artist_credit.artists.artist.gid"),
    # F("artistname", ["artist_credit.name",
    #                            "artist_credit.artists.artist.name"]),
    F("reid", "tracks.medium.release.gid"),
    F("release", "tracks.medium.release.name"),
    F("comment", "comment"),
    F("dur", "length"),
    F("video", "video")
])

SearchReleaseGroup = E(modelext.CustomReleaseGroup, [
    F("mbid", "gid"),
    F("release-group", "name"),
    # F("release", "releases.name"),
    F("reid", "releases.gid"),
])


SCHEMA = {
    "recording": SearchRecording,
    "release-group": SearchReleaseGroup
}

@@ -801,16 +801,128 @@
 .gid%22),%0A
+    F(%22releases%22, %22releases.gid%22, transformfunc=len),%0A    F(%22credit-name%22, %22artist_credit.artists.artist.name%22)%0A
 %5D)%0A%0A%0ASCH

Add missing release group fields