Extensions Paheko  Check-in [98d2aa436f]

Overview
Comment:Merge with ff5b36740b
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dev
Files: files | file ages | folders
SHA1: 98d2aa436f21e48601c3531444a74e6f804b43ee
User & Date: alinaar on 2023-05-12 14:26:14
Other Links: branch diff | manifest | tags
Context
2023-05-13
17:53
HelloAsso: Payments now create genuine paheko accounting transactions check-in: 549e0728bc user: alinaar tags: dev
2023-05-12
14:26
Merge with ff5b36740b check-in: 98d2aa436f user: alinaar tags: dev
14:24
HelloAsso: upgraded to support the new Paheko Payment API check-in: 60995f00eb user: alinaar tags: dev
09:19
Fix stats when something is missing check-in: ff5b36740b user: bohwaz tags: dev
Changes

Modified webstats/install.php from [95aea18725] to [3ee32fadb1].

1


2
3
4

5
6
7
<?php



use Garradin\Plugin\Webstats\Stats;


$db->import(__DIR__ . '/schema.sql');

$plugin->registerSignal('web.request', 'Garradin\Plugin\Webstats\Stats::webRequest');

>
>



>



1
2
3
4
5
6
7
8
9
10
<?php

namespace Garradin;

use Garradin\Plugin\Webstats\Stats;

$db = DB::getInstance();
$db->import(__DIR__ . '/schema.sql');

$plugin->registerSignal('web.request', 'Garradin\Plugin\Webstats\Stats::webRequest');

Modified webstats/lib/Stats.php from [a38e0e40ca] to [26db59aac0].

71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95




96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
		return $db->get('SELECT
			uri,
			hits
			FROM plugin_webstats_hits
			ORDER BY hits DESC LIMIT 50;');
	}

	static public function graph()
	{
		$plot = new Plot(900, 300);

		$data = [];
		$stats = self::getStats();
		$stats = array_reverse($stats);

		foreach ($stats as $month) {
			foreach ((array)$month as $key => $value) {
				if (!isset($data[$key])) {
					$data[$key] = [];
				}

				$data[$key][] = $value;
			}
		}





		$graph = new Plot_Data($data['hits']);
		$graph->title = 'Pages vues';
		$graph->color = 'Crimson';
		$graph->width = 3;
		$plot->add($graph);

		$graph = new Plot_Data($data['visits']);
		$graph->title = 'Visites';
		$graph->color = 'CadetBlue';
		$graph->width = 3;
		$plot->add($graph);

		$graph = new Plot_Data($data['mobile_visits']);
		$graph->title = 'Mobiles';
		$graph->color = 'Salmon';
		$graph->width = 3;
		$plot->add($graph);

		$data['date'] = array_map(fn($a) => substr($a, 5, 2) . '/' . substr($a, 2, 2), $data['date']);
		$plot->setLabels($data['date']);

		return $plot->output();

	}
}







|

















>
>
>
>
|





|





|












71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
		return $db->get('SELECT
			uri,
			hits
			FROM plugin_webstats_hits
			ORDER BY hits DESC LIMIT 50;');
	}

	static public function graph(): ?string
	{
		$plot = new Plot(900, 300);

		$data = [];
		$stats = self::getStats();
		$stats = array_reverse($stats);

		foreach ($stats as $month) {
			foreach ((array)$month as $key => $value) {
				if (!isset($data[$key])) {
					$data[$key] = [];
				}

				$data[$key][] = $value;
			}
		}

		if (!isset($data['date'])) {
			return null;
		}

		$graph = new Plot_Data($data['hits'] ?? []);
		$graph->title = 'Pages vues';
		$graph->color = 'Crimson';
		$graph->width = 3;
		$plot->add($graph);

		$graph = new Plot_Data($data['visits'] ?? []);
		$graph->title = 'Visites';
		$graph->color = 'CadetBlue';
		$graph->width = 3;
		$plot->add($graph);

		$graph = new Plot_Data($data['mobile_visits'] ?? []);
		$graph->title = 'Mobiles';
		$graph->color = 'Salmon';
		$graph->width = 3;
		$plot->add($graph);

		$data['date'] = array_map(fn($a) => substr($a, 5, 2) . '/' . substr($a, 2, 2), $data['date']);
		$plot->setLabels($data['date']);

		return $plot->output();

	}
}