Skip to content
This repository was archived by the owner on Mar 30, 2024. It is now read-only.

Commit 33c6b17

Browse files
committed
Switch to ranges from TTT v1.1.4
1 parent 641ef5b commit 33c6b17

File tree

4 files changed

+38
-18
lines changed

4 files changed

+38
-18
lines changed

VERSION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
latest
2-
0.5.7
3-
0.5
2+
0.6.0
3+
0.6
44
0

php/core/DataAccess.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public function __construct( Login $login, Share $share ) {
3131
public function setParams(string $time, string $rFrom, string $rTo, string $cats, string $names, array $devices ) : void {
3232
$this->cmd = array();
3333
$this->cmdSemantical = array();
34-
35-
$times = array("today", "day", "week", "month", "range", "all");
34+
35+
$times = array("cDay", "cWeek", "cMonth", "cYear", "lDay", "lWeek", "lMonth", "lYear", "range", "all");
3636
if( isset($time) && in_array($time, $times)){
3737
$this->cmd[] = $time;
3838
$this->cmdSemantical['time'] = $time;

php/core/templates/stats_en.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@ <h3>Select data</h3>
88
<label for="time" class="col-sm-2 col-form-label">Timespan</label>
99
<div class="col-sm-10">
1010
<select name="time" id="time" class="custom-select">
11-
<option value="today" selected>Today</option>
12-
<option value="day">Day</option>
13-
<option value="week">Week</option>
14-
<option value="month">Month</option>
11+
<option value="cDay" selected>Today</option>
12+
<option value="cWeek">Current week</option>
13+
<option value="cMonth">Current month</option>
14+
<option value="cYear">Current year</option>
15+
<option value="lDay">Last day (24 hours)</option>
16+
<option value="lWeek">Last week (7 days)</option>
17+
<option value="lMonth">Last month (30 days)</option>
18+
<option value="lYear">Last year (365 days)</option>
1519
<option value="range">Range</option>
1620
<option value="all">All</option>
1721
</select>

php/core/ttt/TTTStats.php

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,42 @@ public function __construct(array $commands, string $path) {
2828

2929
private function parseCommands(array $commands) : void {
3030
switch( $commands[0] ) {
31-
case "day":
32-
$this->backUntil(time() - 86400, array_slice($commands, 1));
31+
case "cDay":
32+
$commands = array_slice($commands, 1);
33+
$this->todayview = true;
34+
$this->backUntil(strtotime("today"), $commands);
35+
case "cWeek":
36+
$this->backUntil(strtotime("last Monday"), array_slice($commands, 1));
37+
break;
38+
case "cMonth":
39+
$this->backUntil(strtotime(date("Y-m")."-01"), array_slice($commands, 1));
40+
break;
41+
case "cYear":
42+
$this->backUntil(strtotime(date("Y")."-01-01"), array_slice($commands, 1));
43+
break;
44+
45+
case "lDay":
46+
$this->backUntil(time() - 24*60*60, array_slice($commands, 1));
3347
break;
34-
case "week":
35-
$this->backUntil(time() - 604800, array_slice($commands, 1));
48+
case "lWeek":
49+
$this->backUntil(time() - 7*24*60*60, array_slice($commands, 1));
3650
break;
37-
case "month":
38-
$this->backUntil(time() - 2628000, array_slice($commands, 1));
51+
case "lMonth":
52+
$this->backUntil(time() - 30*24*60*60, array_slice($commands, 1));
3953
break;
54+
case "lYear":
55+
$this->backUntil(time() - 365*24*60*60, array_slice($commands, 1));
56+
break;
57+
4058
case "all":
4159
$this->backUntil(0, array_slice($commands, 1));
4260
break;
4361
case "range":
4462
$this->rangeStats(array_slice($commands, 1));
4563
break;
46-
case "today":
47-
$commands = array_slice($commands, 1);
64+
4865
default:
49-
$this->todayview = true;
50-
$this->backUntil(strtotime("today"), $commands);
66+
# will not happen, cause command checked in DataAccess
5167
}
5268
}
5369

0 commit comments

Comments
 (0)