mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
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"
|
||||
IntervalLastMonth string = "month"
|
||||
IntervalLastYear string = "year"
|
||||
IntervalAny string = "any"
|
||||
)
|
||||
|
||||
type SummaryHandler struct {
|
||||
@ -60,6 +61,8 @@ func (h *SummaryHandler) Get(w http.ResponseWriter, r *http.Request) {
|
||||
from = utils.StartOfMonth()
|
||||
case IntervalLastYear:
|
||||
from = utils.StartOfYear()
|
||||
case IntervalAny:
|
||||
from = time.Time{}
|
||||
default:
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
w.Write([]byte("missing 'from' parameter"))
|
||||
|
@ -61,15 +61,21 @@
|
||||
<h1>Wakapi</h1>
|
||||
<h3>Your Coding Statistics Dashboard</h3>
|
||||
<div class="input-container" id="input-container">
|
||||
<label for="user">User: </label>
|
||||
<input type="text" class="input" id="user-input" name="user" placeholder="Enter Username">
|
||||
<label for="pw">Password: </label>
|
||||
<input type="password" class="input" id="password-input" name="pw" placeholder="Enter Password">
|
||||
<button onclick="load('today', true)">Today (live)</button>
|
||||
<button onclick="load('day', false)">Day</button>
|
||||
<button onclick="load('week', false)">Week</button>
|
||||
<button onclick="load('month', false)">Month</button>
|
||||
<button onclick="load('year', false)">Year</button>
|
||||
<div>
|
||||
<label for="user">User: </label>
|
||||
<input type="text" class="input" id="user-input" name="user" placeholder="Enter Username">
|
||||
<label for="pw">Password: </label>
|
||||
<input type="password" class="input" id="password-input" name="pw" placeholder="Enter Password">
|
||||
</div>
|
||||
<div style="margin-top: 10px">
|
||||
<span>Shortcuts: </span>
|
||||
<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 class="grid-container" id="grid-container">
|
||||
<div class="header-container">
|
||||
|
@ -20,7 +20,7 @@ func StartOfMonth() time.Time {
|
||||
|
||||
func StartOfYear() time.Time {
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user