summaryrefslogtreecommitdiff
path: root/lib/Multi
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-11-12 20:15:32 +0100
committerYorhel <git@yorhel.nl>2019-11-12 20:19:55 +0100
commit06bacb61526f3945520dd344821d2aa7b85a5f43 (patch)
tree81e7469ab7ac1c1e3e2a80f79cf49022083f89b6 /lib/Multi
parente525c5fb92612e5459ab04b1c010fb88a3dfa22a (diff)
v2rw: Move entryLinks() into separate VNDB::ExtLinks module
This is yak shaving. The new module doesn't have much value as it is, apart from having a central place to define link formats. This new enrich_extlinks() approach is also a bit more efficient in that it can avoid separate SQL queries for multiple objects. But the real reason for these changes is that I can use that %LINKS hash table to automatically generate the links part in the edit summary and it should (hopefully) also be useful to generate a more convenient/streamlined Elm edit form.
Diffstat (limited to 'lib/Multi')
-rw-r--r--lib/Multi/Wikidata.pm34
1 files changed, 5 insertions, 29 deletions
diff --git a/lib/Multi/Wikidata.pm b/lib/Multi/Wikidata.pm
index a618f623..d54fbc8b 100644
--- a/lib/Multi/Wikidata.pm
+++ b/lib/Multi/Wikidata.pm
@@ -11,6 +11,7 @@ use Multi::Core;
use JSON::XS 'decode_json';
use AnyEvent::HTTP;
use VNDB::Config;
+use VNDB::ExtLinks;
my %C = (
@@ -56,35 +57,10 @@ sub fetch {
}
-my %props = (
- P856 => [ 'website', 'text' ],
- P3180 => [ 'vndb', 'text' ],
- P1933 => [ 'mobygames', 'text' ],
- P4773 => [ 'mobygames_company', 'text' ],
- P4769 => [ 'gamefaqs_game', 'integer' ],
- P6182 => [ 'gamefaqs_company', 'integer' ],
- P5646 => [ 'anidb_anime', 'integer' ],
- P5649 => [ 'anidb_person', 'integer' ],
- P1985 => [ 'ann_anime', 'integer' ],
- P1984 => [ 'ann_manga', 'integer' ],
- P434 => [ 'musicbrainz_artist', 'uuid' ],
- P2002 => [ 'twitter', 'text' ],
- P5659 => [ 'vgmdb_product', 'integer' ],
- P3435 => [ 'vgmdb_artist', 'integer' ],
- P1953 => [ 'discogs_artist', 'integer' ],
- P7013 => [ 'acdb_char', 'integer' ],
- P7017 => [ 'acdb_source', 'integer' ],
- P6717 => [ 'indiedb_game', 'text' ],
- P2816 => [ 'howlongtobeat', 'integer' ],
- P4110 => [ 'crunchyroll', 'text' ],
- P5794 => [ 'igdb_game', 'text' ],
- P5247 => [ 'giantbomb', 'text' ],
- P6337 => [ 'pcgamingwiki ', 'text' ],
- P1733 => [ 'steam', 'integer' ],
- P2725 => [ 'gog', 'text' ],
- P5435 => [ 'pixiv_user', 'integer' ],
- P7511 => [ 'doujinshi_author', 'integer' ],
-);
+# property_id -> [ column name, sql element type ]
+my %props =
+ map +($VNDB::ExtLinks::WIKIDATA{$_}{property}, [ $_, $VNDB::ExtLinks::WIKIDATA{$_}{type} =~ s/\[\]$//r ]),
+ grep $VNDB::ExtLinks::WIKIDATA{$_}{property}, keys %VNDB::ExtLinks::WIKIDATA;
sub process {