mirror of https://github.com/muety/wakapi.git
Fix start of year computation.
Add shortcut to get lifetime statistics.
This commit is contained in:
parent
4ae53746c3
commit
d583dd312b
|
@ -19,6 +19,7 @@ const (
|
||||||
IntervalLastWeek string = "week"
|
IntervalLastWeek string = "week"
|
||||||
IntervalLastMonth string = "month"
|
IntervalLastMonth string = "month"
|
||||||
IntervalLastYear string = "year"
|
IntervalLastYear string = "year"
|
||||||
|
IntervalAny string = "any"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SummaryHandler struct {
|
type SummaryHandler struct {
|
||||||
|
@ -60,6 +61,8 @@ func (h *SummaryHandler) Get(w http.ResponseWriter, r *http.Request) {
|
||||||
from = utils.StartOfMonth()
|
from = utils.StartOfMonth()
|
||||||
case IntervalLastYear:
|
case IntervalLastYear:
|
||||||
from = utils.StartOfYear()
|
from = utils.StartOfYear()
|
||||||
|
case IntervalAny:
|
||||||
|
from = time.Time{}
|
||||||
default:
|
default:
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
w.Write([]byte("missing 'from' parameter"))
|
w.Write([]byte("missing 'from' parameter"))
|
||||||
|
|
|
@ -61,15 +61,21 @@
|
||||||
<h1>Wakapi</h1>
|
<h1>Wakapi</h1>
|
||||||
<h3>Your Coding Statistics Dashboard</h3>
|
<h3>Your Coding Statistics Dashboard</h3>
|
||||||
<div class="input-container" id="input-container">
|
<div class="input-container" id="input-container">
|
||||||
<label for="user">User: </label>
|
<div>
|
||||||
<input type="text" class="input" id="user-input" name="user" placeholder="Enter Username">
|
<label for="user">User: </label>
|
||||||
<label for="pw">Password: </label>
|
<input type="text" class="input" id="user-input" name="user" placeholder="Enter Username">
|
||||||
<input type="password" class="input" id="password-input" name="pw" placeholder="Enter Password">
|
<label for="pw">Password: </label>
|
||||||
<button onclick="load('today', true)">Today (live)</button>
|
<input type="password" class="input" id="password-input" name="pw" placeholder="Enter Password">
|
||||||
<button onclick="load('day', false)">Day</button>
|
</div>
|
||||||
<button onclick="load('week', false)">Week</button>
|
<div style="margin-top: 10px">
|
||||||
<button onclick="load('month', false)">Month</button>
|
<span>Shortcuts: </span>
|
||||||
<button onclick="load('year', false)">Year</button>
|
<button onclick="load('today', true)">Today (live)</button>
|
||||||
|
<button onclick="load('day', false)">Yesterday</button>
|
||||||
|
<button onclick="load('week', false)">This Week</button>
|
||||||
|
<button onclick="load('month', false)">This Month</button>
|
||||||
|
<button onclick="load('year', false)">This Year</button>
|
||||||
|
<button onclick="load('any', false)">All Time</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid-container" id="grid-container">
|
<div class="grid-container" id="grid-container">
|
||||||
<div class="header-container">
|
<div class="header-container">
|
||||||
|
|
|
@ -20,7 +20,7 @@ func StartOfMonth() time.Time {
|
||||||
|
|
||||||
func StartOfYear() time.Time {
|
func StartOfYear() time.Time {
|
||||||
ref := time.Now()
|
ref := time.Now()
|
||||||
return time.Date(ref.Year(), 0, 0, 0, 0, 0, 0, ref.Location())
|
return time.Date(ref.Year(), time.January, 0, 0, 0, 0, 0, ref.Location())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://stackoverflow.com/a/18632496
|
// https://stackoverflow.com/a/18632496
|
||||||
|
|
Loading…
Reference in New Issue