Check-in [840066990b]
Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | update to GraphQL query |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
840066990bda713211a6c3c70b6b2d01 |
User & Date: | mario 2022-06-05 21:30:31 |
Context
2024-06-19
| ||
15:36 | work around overlength release notes (HTML remnants) check-in: 9013b83e6f user: mario tags: trunk | |
2022-06-05
| ||
21:30 | update to GraphQL query check-in: 840066990b user: mario tags: trunk | |
2021-12-26
| ||
18:13 | Add fossforce, remove xyz-apps.org (dead for good?, albeit kde had a similar app store now) check-in: eecd325303 user: mario tags: trunk | |
Changes
Changes to cron.daily/header_stats.php.
1 2 3 4 | <?php /** * title: statistics * description: generate statistics, visitors, projects, autoupdate, etc. for header | | < < | > > | | > > > > > > > > > > > > > > > > | < > > > > > > > > > > > > > > > > | | < | | < > | | > > > | | > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | <?php /** * title: statistics * description: generate statistics, visitors, projects, autoupdate, etc. for header * version: 0.3 * depends: * category: template * type: cron * x-cron: 11 23,5,16 * * * * * Approximate weekly numbers by multiplication. * */ chdir(dirname(__DIR__)); include("config.php"); // get CloudFlare visitor stats // https://developers.cloudflare.com/analytics/graphql-api/migration-guides/zone-analytics/ $ZONE_ID = "e373b910a645ebccd6035d4b38a2fe4c"; $date = new DateTime(""); $date->sub(new DateInterval("P7D")); $date = $date->format("Y-m-d"); $payload = <<<GRAPHQL { viewer { zones(filter: {zoneTag: $ZONE_ID}) { httpRequests1dGroups(orderBy: [date_ASC], limit: 100, filter:{date_geq: "$date"}) { dimensions { date } sum { bytes cachedBytes cachedRequests countryMap { bytes requests threats clientCountryName } encryptedBytes encryptedRequests pageViews requests threats } uniq { uniques } } } } } GRAPHQL; $json = curl() #->url("https://api.cloudflare.com/client/v4/user/tokens/verify") ->url("https://api.cloudflare.com/client/v4/graphql") ->httpheader([ "X-Auth-Email: " . CLOUDFLARE_EMAIL, "X-Auth-Key: " . CLOUDFLARE_KEY, "Authorization: Bearer " . COUDFLARE_TKN2, "Content-Type: application/json", ]) ->postfields(json_encode(["query"=>$payload])) ->exec(); $stats = json_decode($json); $stats = $stats->data->viewer->zones[0]->httpRequests1dGroups; #print_r($stats); #exit(); $s_visitors = 0; $s_pageviews = 0; foreach ($stats as $ds) { $s_visitors += $ds->uniq->uniques; $s_pageviews += $ds->sum->requests; } // number of projects $s_num_proj = db("SELECT COUNT(name) AS cnt FROM (SELECT name FROM release GROUP BY name)")->cnt; // releases $s_num_vers = db("SELECT COUNT(name) AS cnt FROM (SELECT DISTINCT name, version FROM release WHERE version != ?)", "")->cnt; |
︙ | ︙ |