Jdlrobson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/180683
Change subject: Serve description even if the wiki data item has no instance of
claims
......................................................................
Serve description even if the wiki data item has no instance of claims
Change-Id: I7a9645932db5414cbe8dee0c53e686a57ce4ab47
---
M javascripts/modules/wikigrok/WikiDataApi.js
1 file changed, 33 insertions(+), 35 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/83/180683/1
diff --git a/javascripts/modules/wikigrok/WikiDataApi.js
b/javascripts/modules/wikigrok/WikiDataApi.js
index 08b5500..b653436 100644
--- a/javascripts/modules/wikigrok/WikiDataApi.js
+++ b/javascripts/modules/wikigrok/WikiDataApi.js
@@ -83,34 +83,36 @@
} ).then( function ( data ) {
var description, instanceClaims, entityClaims,
instanceOf,
claims = {};
- // See if the page has any 'instance of' claims.
if (
data.entities !== undefined &&
- data.entities[id].claims !== undefined
&&
- data.entities[id].claims.P31 !==
undefined
+ data.entities[id].claims !== undefined
) {
entityClaims = data.entities[id].claims;
- instanceClaims = entityClaims.P31;
- // Examine claims closely
- $.each( instanceClaims, function ( i,
claim ) {
- instanceOf =
claim.mainsnak.datavalue.value['numeric-id'];
- if ( instanceOf === 5 ) {
- claims.isHuman = true;
- } else if ( instanceOf === 515
) {
- claims.isCity = true;
- } else if ( instanceOf === 6256
) {
- claims.isCountry = true;
- } else if ( instanceOf ===
16521 ) {
- claims.isTaxon = true;
- } else if ( instanceOf ===
11424 ) {
- claims.isMovie = true;
- } else if ( instanceOf ===
5398426 ) {
- claims.isTVSeries =
true;
- }
- // Note: bands are subclassed
as rock band, punk band etc.. not sure how we want
- // to include them here.
- } );
+ // See if the page has any 'instance
of' claims.
+ if ( data.entities[id].claims.P31 !==
undefined ) {
+ instanceClaims =
entityClaims.P31;
+
+ // Examine claims closely
+ $.each( instanceClaims,
function ( i, claim ) {
+ instanceOf =
claim.mainsnak.datavalue.value['numeric-id'];
+ if ( instanceOf === 5 )
{
+ claims.isHuman
= true;
+ } else if ( instanceOf
=== 515 ) {
+ claims.isCity =
true;
+ } else if ( instanceOf
=== 6256 ) {
+
claims.isCountry = true;
+ } else if ( instanceOf
=== 16521 ) {
+ claims.isTaxon
= true;
+ } else if ( instanceOf
=== 11424 ) {
+ claims.isMovie
= true;
+ } else if ( instanceOf
=== 5398426 ) {
+
claims.isTVSeries = true;
+ }
+ // Note: bands are
subclassed as rock band, punk band etc.. not sure how we want
+ // to include them here.
+ } );
+ }
// set some claims
claims.hasOccupation =
entityClaims.P106 ? true : false;
@@ -119,19 +121,15 @@
claims.hasDateOfDeath =
entityClaims.P570 ? true : false;
claims.entities = entityClaims;
- description = data.entities[ id ];
-
- if ( description &&
description.descriptions !== undefined ) {
- if ( description.descriptions[
self.language ] ) {
- claims.description =
description.descriptions[ self.language ].value;
- }
- }
- return claims;
- } else {
- // FIXME: logError does not exist
- // self.logError(
'no-impression-cannot-fetch-claims' );
- return false;
}
+ description = data.entities[ id ];
+
+ if ( description && description.descriptions
!== undefined ) {
+ if ( description.descriptions[
self.language ] ) {
+ claims.description =
description.descriptions[ self.language ].value;
+ }
+ }
+ return claims;
} ).fail( function () {
// FIXME: logError does not exist
// self.logError(
'no-impression-cannot-fetch-claims' );
--
To view, visit https://gerrit.wikimedia.org/r/180683
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7a9645932db5414cbe8dee0c53e686a57ce4ab47
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits