[MediaWiki-commits] [Gerrit] Count WD query triples - change (analytics/limn-wikidata-data)
Addshore has submitted this change and it was merged. Change subject: Count WD query triples .. Count WD query triples Change-Id: Ib1f80d4cedae53e3ad2e0b3ffc7f0b8f4e2ed739 --- M cron A graphite/sparql/triples.php 2 files changed, 30 insertions(+), 0 deletions(-) Approvals: Addshore: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/cron b/cron index 73b96e6..8bfe753 100644 --- a/cron +++ b/cron @@ -5,6 +5,7 @@ # Run every minuite * * * * * php ~/wikidata-data/graphite/dispatch.php +* * * * * php ~/wikidata-data/graphite/sparql/triples.php # Daily 0 5 * * * php ~/wikidata-data/graphite/entityUsage.php diff --git a/graphite/sparql/triples.php b/graphite/sparql/triples.php new file mode 100644 index 000..2ee5b95 --- /dev/null +++ b/graphite/sparql/triples.php @@ -0,0 +1,29 @@ +execute(); + +class WikidataSparqlTriples{ + + public function execute() { + // WDQS currently caches for 120 seconds, avoid this by adding whitespace + $whiteSpace = str_repeat( ' ', date( 'i' ) ); + + $query = "SELECT ( COUNT( * ) AS ?no ) { ?s ?p ?o $whiteSpace}"; + $response = file_get_contents( "https://query.wikidata.org/bigdata/namespace/wdq/sparql?format=json&query="; . urlencode( $query ) ); + + if( $response === false ) { + throw new RuntimeException( "The request failed!" ); + } + + $data = json_decode( $response, true ); + $value = $data['results']['bindings'][0]['no']['value']; + + exec( "echo \"wikidata.query.triples $value `date +%s`\" | nc -q0 graphite.eqiad.wmnet 2003" ); + } + +} -- To view, visit https://gerrit.wikimedia.org/r/254862 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib1f80d4cedae53e3ad2e0b3ffc7f0b8f4e2ed739 Gerrit-PatchSet: 1 Gerrit-Project: analytics/limn-wikidata-data Gerrit-Branch: master Gerrit-Owner: Addshore Gerrit-Reviewer: Addshore Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Count WD query triples - change (analytics/limn-wikidata-data)
Addshore has uploaded a new change for review. https://gerrit.wikimedia.org/r/254862 Change subject: Count WD query triples .. Count WD query triples Change-Id: Ib1f80d4cedae53e3ad2e0b3ffc7f0b8f4e2ed739 --- M cron A graphite/sparql/triples.php 2 files changed, 30 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/analytics/limn-wikidata-data refs/changes/62/254862/1 diff --git a/cron b/cron index 73b96e6..8bfe753 100644 --- a/cron +++ b/cron @@ -5,6 +5,7 @@ # Run every minuite * * * * * php ~/wikidata-data/graphite/dispatch.php +* * * * * php ~/wikidata-data/graphite/sparql/triples.php # Daily 0 5 * * * php ~/wikidata-data/graphite/entityUsage.php diff --git a/graphite/sparql/triples.php b/graphite/sparql/triples.php new file mode 100644 index 000..2ee5b95 --- /dev/null +++ b/graphite/sparql/triples.php @@ -0,0 +1,29 @@ +execute(); + +class WikidataSparqlTriples{ + + public function execute() { + // WDQS currently caches for 120 seconds, avoid this by adding whitespace + $whiteSpace = str_repeat( ' ', date( 'i' ) ); + + $query = "SELECT ( COUNT( * ) AS ?no ) { ?s ?p ?o $whiteSpace}"; + $response = file_get_contents( "https://query.wikidata.org/bigdata/namespace/wdq/sparql?format=json&query="; . urlencode( $query ) ); + + if( $response === false ) { + throw new RuntimeException( "The request failed!" ); + } + + $data = json_decode( $response, true ); + $value = $data['results']['bindings'][0]['no']['value']; + + exec( "echo \"wikidata.query.triples $value `date +%s`\" | nc -q0 graphite.eqiad.wmnet 2003" ); + } + +} -- To view, visit https://gerrit.wikimedia.org/r/254862 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib1f80d4cedae53e3ad2e0b3ffc7f0b8f4e2ed739 Gerrit-PatchSet: 1 Gerrit-Project: analytics/limn-wikidata-data Gerrit-Branch: master Gerrit-Owner: Addshore ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits