jenkins-bot has submitted this change and it was merged. Change subject: Include the campaign property's Wikidata label ......................................................................
Include the campaign property's Wikidata label * Add the WikiGrok\WikibaseConnector#getLabelForProperty method, which returns the label for the property in the content language of the host wiki * Modify WikiGrok\QuestionPicker#getQuestions to filter campaigns that don't have labels and to include the labels in its result * Migrating the property ID from 'property' to 'propertyId' * Incrementing FORMAT_VERSION Change-Id: I97bfd010ac18b6a6ef8129086028c040df38f4fc --- M includes/QuestionPicker.php M includes/QuestionStore.php M includes/WikibaseConnector.php 3 files changed, 27 insertions(+), 3 deletions(-) Approvals: Kaldari: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/QuestionPicker.php b/includes/QuestionPicker.php index 5b12ac5..6971c04 100644 --- a/includes/QuestionPicker.php +++ b/includes/QuestionPicker.php @@ -52,6 +52,8 @@ $requestedProps = array(); $linkedProps = array(); $linkSearchOnly = true; + $campaignPropertyLabels = array(); + foreach ( $campaigns as $campaign ) { $requestedProps += $campaign->getRequestedCurrentPageProps(); $linkSearchOnly = $linkSearchOnly && $campaign->getNumLinks() > 0; @@ -66,6 +68,16 @@ unset( $campaigns[$name] ); continue; } + + $campaignPropertyLabel = $this->wikibase->getLabelForProperty( $campaign->getProperty() ); + + if ( !$campaignPropertyLabel ) { + unset( $campaigns[$name] ); + continue; + } + + $campaignPropertyLabels[$name] = $campaignPropertyLabel; + $numLinks = max( $numLinks, $campaign->getNumLinks() ); $linkedProps += $campaign->getRequestedLinkedProps(); } @@ -85,7 +97,8 @@ $suggestions = $campaign->getQuestions( $props, $data ); if ( $suggestions ) { $results[$name] = array( - 'property' => $campaign->getProperty(), + 'propertyId' => $campaign->getProperty(), + 'propertyName' => $campaignPropertyLabels[$name], 'questions' => $suggestions, ); diff --git a/includes/QuestionStore.php b/includes/QuestionStore.php index 5772ccb..2279ed9 100644 --- a/includes/QuestionStore.php +++ b/includes/QuestionStore.php @@ -9,7 +9,7 @@ * Stores campaign questions in a permanent storage */ class QuestionStore { - const FORMAT_VERSION = 1; + const FORMAT_VERSION = 2; public function store( Title $title, array $campaigns ) { $profileSection = new ProfileSection( __METHOD__ ); diff --git a/includes/WikibaseConnector.php b/includes/WikibaseConnector.php index 5ecfb1d..40f45c9 100644 --- a/includes/WikibaseConnector.php +++ b/includes/WikibaseConnector.php @@ -97,6 +97,17 @@ } /** + * Gets the Wikidata label of the property in the content language of the + * host wiki. + * + * @param string $property + * @return string + */ + public function getLabelForProperty( $property ) { + return $this->getLabel( new PropertyId( $property ) ); + } + + /** * Returns a list of values of given properties of a given Wikidata item * * @param string $itemId: item identifier @@ -139,4 +150,4 @@ return $values; } -} \ No newline at end of file +} -- To view, visit https://gerrit.wikimedia.org/r/180811 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I97bfd010ac18b6a6ef8129086028c040df38f4fc Gerrit-PatchSet: 5 Gerrit-Project: mediawiki/extensions/WikiGrok Gerrit-Branch: master Gerrit-Owner: Phuedx <g...@samsmith.io> Gerrit-Reviewer: Kaldari <rkald...@wikimedia.org> Gerrit-Reviewer: MaxSem <maxsem.w...@gmail.com> Gerrit-Reviewer: Phuedx <g...@samsmith.io> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits