From 4d6b2b9339b77ca6c1437c5810223e636323f7ee Mon Sep 17 00:00:00 2001 From: Gargaj Date: Tue, 10 Oct 2017 17:31:29 +0200 Subject: [PATCH] add stats API --- _rewrite.php | 2 ++ index.html | 1 + v1_stats.php | 27 +++++++++++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 v1_stats.php diff --git a/_rewrite.php b/_rewrite.php index 6ec9c46..3856a96 100644 --- a/_rewrite.php +++ b/_rewrite.php @@ -11,6 +11,8 @@ "^\/+v1\/party\/?$" => "v1_party.php", + "^\/+v1\/stats\/?$" => "v1_stats.php", + "^\/+adhoc\/prods-from-year\/?$" => "adhoc_prods_year.php", )); $r->addBootstrap("./functions.inc.php"); diff --git a/index.html b/index.html index 5c748ce..b6793e5 100644 --- a/index.html +++ b/index.html @@ -15,6 +15,7 @@

Endpoints

http://api.pouet.net/v1/group/?id=1
http://api.pouet.net/v1/search/prod/?q=[...]
http://api.pouet.net/v1/party/?id=1&year=2000
+
http://api.pouet.net/v1/stats/

More to come, mostly on demand. Data structures are subject to change without notice.

diff --git a/v1_stats.php b/v1_stats.php new file mode 100644 index 0000000..1e64200 --- /dev/null +++ b/v1_stats.php @@ -0,0 +1,27 @@ +AddWhere(sprintf_esc("(prods.group1 = %d) or (prods.group2 = %d) or (prods.group3 = %d)",$group->id,$group->id,$group->id)); + $prods = $s->perform(); + PouetCollectPlatforms($prods); + PouetCollectAwards($prods); +} + +$result = new stdClass(); + +$data = unserialize( file_get_contents( POUETAPI_POUET_ROOT_LOCAL . "/cache/pouetbox_stats.cache" ) ); +if ($data) +{ + $result->success = true; + $result->stats = $data; +} +else +{ + $result->error = true; +} +output($result); +?> \ No newline at end of file