forked from lolli42/Repo-Activity-Monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
core-stat.php
executable file
·40 lines (29 loc) · 1.09 KB
/
core-stat.php
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
<?php
error_reporting(E_ALL ^ E_NOTICE);
const TEMPLATE_PATH = 'Templates/';
require_once('TemplateEngine.php');
require_once('StatGenerator.php');
require_once('JsonFormatter.php');
require_once('TableFormatter.php');
$baseDir = isset($argv[1]) ? $argv[1] : getcwd();
$baseDir .= substr($baseDir, -1) == '/' ? '' : '/';
$dataDir = isset($argv[2]) ? $argv[2] : getcwd();
$dataDir .= substr($dataDir, -1) == '/' ? '' : '/';
$statisticsTemplate = new TemplateEngine('StatisticsTemplate');
$table = new TableFormatter();
$modules = array('.');
$startdate = '2006-01-01';
$generator = new StatGenerator($dataDir, $baseDir, $startdate);
list($persons, $commitCounts) = $generator->generateData($modules);
$json = new JsonFormatter();
file_put_contents($dataDir . 'json.php', $json->generate($persons, $commitCounts, $generator->getMaxMonths()));
$statisticsTemplate->replaceMarkerArray(
array (
'last_update' => date('Y-m-d H:i', time()),
'table' => $table->generate($persons, $commitCounts, $generator->getMaxMonths())
)
);
file_put_contents(
$dataDir . 'stat.html',
$statisticsTemplate->getTemplate()
);