[mb-commits] branch, mbs-5609, created. MBS-5609, enable release relationships and include relationship dates in / ws/...
MusicBrainz Git Server <[email protected]>
| Newsgroups | gmane.comp.audio.musicbrainz.cvs |
|---|---|
| Message-ID | <E1TilMj-0000D2-Up@wiley> |
The branch, mbs-5609 has been created
at 66d6b59e500f40ab26bd085e4c8478d201c2fe67 (commit)
- Log -----------------------------------------------------------------
commit 66d6b59e500f40ab26bd085e4c8478d201c2fe67
Author: warp <[email protected]>
Date: Wed Dec 12 13:23:51 2012 +0100
MBS-5609, enable release relationships and include relationship dates in /ws/2 json webservice.
diff --git a/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Relation.pm b/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Relation.pm
index 49a492f..ad475ac 100644
--- a/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Relation.pm
+++ b/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Relation.pm
@@ -2,7 +2,7 @@ package MusicBrainz::Server::WebService::Serializer::JSON::2::Relation;
use Moose;
use String::CamelCase qw(camelize);
-use MusicBrainz::Server::WebService::Serializer::JSON::2::Utils qw(serialize_entity);
+use MusicBrainz::Server::WebService::Serializer::JSON::2::Utils qw(boolean serialize_entity);
extends 'MusicBrainz::Server::WebService::Serializer::JSON::2';
@@ -16,9 +16,14 @@ sub serialize
$body{type} = $entity->link->type->name;
$body{direction} = $entity->direction == 2 ? "backward" : "forward";
+ my $link = $entity->link;
+ $body{begin} = $link->begin_date->is_empty ? JSON::null : $link->begin_date->format;
+ $body{end} = $link->end_date->is_empty ? JSON::null : $link->end_date->format;
+ $body{ended} = boolean ($link->ended);
+
if ($entity->target_type eq 'artist' ||
$entity->target_type eq 'label' ||
- # $entity->target_type eq 'release' ||
+ $entity->target_type eq 'release' ||
$entity->target_type eq 'recording')
{
$body{$entity->target_type} = serialize_entity ($entity->target);
diff --git a/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Release.pm b/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Release.pm
index c86fe33..74aa61b 100644
--- a/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Release.pm
+++ b/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Release.pm
@@ -61,7 +61,7 @@ sub serialize
else
{
$body{"artist-credit"} = serialize_entity ($entity->artist_credit, $inc, $stash)
- if $inc->artist_credits;
+ if $inc && $inc->artist_credits;
}
$body{"label-info"} = [
@@ -72,7 +72,7 @@ sub serialize
}
} @{ $entity->labels } ] if $toplevel && $inc->labels;
- if ($inc->media || $inc->discids || $inc->recordings)
+ if ($inc && ($inc->media || $inc->discids || $inc->recordings))
{
$body{media} = [
map { serialize_entity($_, $inc, $stash) }
diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm
index fd5e547..7a836b9 100644
--- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm
+++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm
@@ -128,29 +128,43 @@ test 'basic artist lookup, inc=url-rels' => sub {
{
direction => "forward",
url => "http://farm4.static.flickr.com/3652/3334818186_6e19173c33_b.jpg",
- type => "image"
- },
+ type => "image",
+ begin => JSON::null,
+ end => JSON::null,
+ ended => JSON::false,
+ },
{
direction => "forward",
url => "http://members.boardhost.com/wedlock/",
- type => "online community"
- },
+ type => "online community",
+ begin => JSON::null,
+ end => JSON::null,
+ ended => JSON::false,
+ },
{
direction => "forward",
url => "http://www.discogs.com/artist/Paul+Allgood",
- type => "discogs"
- },
+ type => "discogs",
+ begin => JSON::null,
+ end => JSON::null,
+ ended => JSON::false,
+ },
{
direction => "forward",
url => "http://www.imdb.com/name/nm4057169/",
- type => "IMDb"
- },
+ type => "IMDb",
+ begin => JSON::null,
+ end => JSON::null,
+ ended => JSON::false,
+ },
{
direction => "forward",
url => "http://www.paulallgood.com/",
- type => "blog"
- },
- ],
+ type => "blog",
+ begin => JSON::null,
+ end => JSON::null,
+ ended => JSON::false,
+ }],
});
};
diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupWork.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupWork.pm
index a161ff0..0928998 100644
--- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupWork.pm
+++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupWork.pm
@@ -92,7 +92,10 @@ test 'work lookup with recording relationships' => sub {
title => "サマーれげぇ!レインボー",
length => 296026,
disambiguation => "",
- }
+ },
+ begin => JSON::null,
+ end => JSON::null,
+ ended => JSON::false,
},
{
type => "performance",
@@ -102,7 +105,10 @@ test 'work lookup with recording relationships' => sub {
title => "サマーれげぇ!レインボー (instrumental)",
length => 292800,
disambiguation => "",
- }
+ },
+ begin => JSON::null,
+ end => JSON::null,
+ ended => JSON::false,
}
],
iswcs => [],
-----------------------------------------------------------------------
hooks/post-receive
--
mb_server
_______________________________________________
MusicBrainz-commits mailing list
[email protected]
http://lists.musicbrainz.org/mailman/listinfo/musicbrainz-commits