1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

Add last_6_months interval identifier

This commit is contained in:
Marvin Scham 2022-08-19 17:14:00 +02:00
parent 4bfc8a9e9f
commit 9505773165
No known key found for this signature in database
GPG Key ID: 2674E9764DF35025
10 changed files with 65 additions and 12 deletions

View File

@ -14,6 +14,7 @@ var (
IntervalPast7DaysYesterday = &IntervalKey{"Last 7 Days from Yesterday"} IntervalPast7DaysYesterday = &IntervalKey{"Last 7 Days from Yesterday"}
IntervalPast14Days = &IntervalKey{"Last 14 Days"} IntervalPast14Days = &IntervalKey{"Last 14 Days"}
IntervalPast30Days = &IntervalKey{"30_days", "last_30_days", "Last 30 Days"} IntervalPast30Days = &IntervalKey{"30_days", "last_30_days", "Last 30 Days"}
IntervalPast6Months = &IntervalKey{"6_months", "last_6_months"}
IntervalPast12Months = &IntervalKey{"12_months", "last_12_months", "last_year"} IntervalPast12Months = &IntervalKey{"12_months", "last_12_months", "last_year"}
IntervalAny = &IntervalKey{"any", "all_time"} IntervalAny = &IntervalKey{"any", "all_time"}
) )
@ -30,6 +31,7 @@ var AllIntervals = []*IntervalKey{
IntervalPast7DaysYesterday, IntervalPast7DaysYesterday,
IntervalPast14Days, IntervalPast14Days,
IntervalPast30Days, IntervalPast30Days,
IntervalPast6Months,
IntervalPast12Months, IntervalPast12Months,
IntervalAny, IntervalAny,
} }

View File

@ -37,7 +37,7 @@ func (h *SummaryApiHandler) RegisterRoutes(router *mux.Router) {
// @ID get-summary // @ID get-summary
// @Tags summary // @Tags summary
// @Produce json // @Produce json
// @Param interval query string false "Interval identifier" Enums(today, yesterday, week, month, year, 7_days, last_7_days, 30_days, last_30_days, 12_months, last_12_months, any) // @Param interval query string false "Interval identifier" Enums(today, yesterday, week, month, year, 7_days, last_7_days, 30_days, last_30_days, 6_months, last_6_months, 12_months, last_12_months, last_year, any, all_time)
// @Param from query string false "Start date (e.g. '2021-02-07')" // @Param from query string false "Start date (e.g. '2021-02-07')"
// @Param to query string false "End date (e.g. '2021-02-08')" // @Param to query string false "End date (e.g. '2021-02-08')"
// @Param recompute query bool false "Whether to recompute the summary from raw heartbeat or use cache" // @Param recompute query bool false "Whether to recompute the summary from raw heartbeat or use cache"

View File

@ -43,7 +43,7 @@ func (h *BadgeHandler) RegisterRoutes(router *mux.Router) {
// @Tags badges // @Tags badges
// @Produce json // @Produce json
// @Param user path string true "User ID to fetch data for" // @Param user path string true "User ID to fetch data for"
// @Param interval path string true "Interval to aggregate data for" Enums(today, yesterday, week, month, year, 7_days, last_7_days, 30_days, last_30_days, 12_months, last_12_months, any) // @Param interval path string true "Interval to aggregate data for" Enums(today, yesterday, week, month, year, 7_days, last_7_days, 30_days, last_30_days, 6_months, last_6_months, 12_months, last_12_months, last_year, any, all_time)
// @Param filter path string true "Filter to apply (e.g. 'project:wakapi' or 'language:Go')" // @Param filter path string true "Filter to apply (e.g. 'project:wakapi' or 'language:Go')"
// @Success 200 {object} v1.BadgeData // @Success 200 {object} v1.BadgeData
// @Router /compat/shields/v1/{user}/{interval}/{filter} [get] // @Router /compat/shields/v1/{user}/{interval}/{filter} [get]

View File

@ -48,7 +48,7 @@ func (h *StatsHandler) RegisterRoutes(router *mux.Router) {
// @Tags wakatime // @Tags wakatime
// @Produce json // @Produce json
// @Param user path string true "User ID to fetch data for (or 'current')" // @Param user path string true "User ID to fetch data for (or 'current')"
// @Param range path string false "Range interval identifier" Enums(today, yesterday, week, month, year, 7_days, last_7_days, 30_days, last_30_days, 12_months, last_12_months, any) // @Param range path string false "Range interval identifier" Enums(today, yesterday, week, month, year, 7_days, last_7_days, 30_days, last_30_days, 6_months, last_6_months, 12_months, last_12_months, last_year, any, all_time)
// @Param project query string false "Project to filter by" // @Param project query string false "Project to filter by"
// @Param language query string false "Language to filter by" // @Param language query string false "Language to filter by"
// @Param editor query string false "Editor to filter by" // @Param editor query string false "Editor to filter by"

View File

@ -50,7 +50,7 @@ func (h *SummariesHandler) RegisterRoutes(router *mux.Router) {
// @Tags wakatime // @Tags wakatime
// @Produce json // @Produce json
// @Param user path string true "User ID to fetch data for (or 'current')" // @Param user path string true "User ID to fetch data for (or 'current')"
// @Param range query string false "Range interval identifier" Enums(today, yesterday, week, month, year, 7_days, last_7_days, 30_days, last_30_days, 12_months, last_12_months, any) // @Param range query string false "Range interval identifier" Enums(today, yesterday, week, month, year, 7_days, last_7_days, 30_days, last_30_days, 6_months, last_6_months, 12_months, last_12_months, last_year, any, all_time)
// @Param start query string false "Start date (e.g. '2021-02-07')" // @Param start query string false "Start date (e.g. '2021-02-07')"
// @Param end query string false "End date (e.g. '2021-02-08')" // @Param end query string false "End date (e.g. '2021-02-08')"
// @Param project query string false "Project to filter by" // @Param project query string false "Project to filter by"

View File

@ -54,9 +54,13 @@ const docTemplate = `{
"last_7_days", "last_7_days",
"30_days", "30_days",
"last_30_days", "last_30_days",
"6_months",
"last_6_months",
"12_months", "12_months",
"last_12_months", "last_12_months",
"any" "last_year",
"any",
"all_time"
], ],
"type": "string", "type": "string",
"description": "Interval to aggregate data for", "description": "Interval to aggregate data for",
@ -354,9 +358,13 @@ const docTemplate = `{
"last_7_days", "last_7_days",
"30_days", "30_days",
"last_30_days", "last_30_days",
"6_months",
"last_6_months",
"12_months", "12_months",
"last_12_months", "last_12_months",
"any" "last_year",
"any",
"all_time"
], ],
"type": "string", "type": "string",
"description": "Range interval identifier", "description": "Range interval identifier",
@ -445,9 +453,13 @@ const docTemplate = `{
"last_7_days", "last_7_days",
"30_days", "30_days",
"last_30_days", "last_30_days",
"6_months",
"last_6_months",
"12_months", "12_months",
"last_12_months", "last_12_months",
"any" "last_year",
"any",
"all_time"
], ],
"type": "string", "type": "string",
"description": "Range interval identifier", "description": "Range interval identifier",
@ -809,9 +821,13 @@ const docTemplate = `{
"last_7_days", "last_7_days",
"30_days", "30_days",
"last_30_days", "last_30_days",
"6_months",
"last_6_months",
"12_months", "12_months",
"last_12_months", "last_12_months",
"any" "last_year",
"any",
"all_time"
], ],
"type": "string", "type": "string",
"description": "Interval identifier", "description": "Interval identifier",

View File

@ -46,9 +46,13 @@
"last_7_days", "last_7_days",
"30_days", "30_days",
"last_30_days", "last_30_days",
"6_months",
"last_6_months",
"12_months", "12_months",
"last_12_months", "last_12_months",
"any" "last_year",
"any",
"all_time"
], ],
"type": "string", "type": "string",
"description": "Interval to aggregate data for", "description": "Interval to aggregate data for",
@ -346,9 +350,13 @@
"last_7_days", "last_7_days",
"30_days", "30_days",
"last_30_days", "last_30_days",
"6_months",
"last_6_months",
"12_months", "12_months",
"last_12_months", "last_12_months",
"any" "last_year",
"any",
"all_time"
], ],
"type": "string", "type": "string",
"description": "Range interval identifier", "description": "Range interval identifier",
@ -437,9 +445,13 @@
"last_7_days", "last_7_days",
"30_days", "30_days",
"last_30_days", "last_30_days",
"6_months",
"last_6_months",
"12_months", "12_months",
"last_12_months", "last_12_months",
"any" "last_year",
"any",
"all_time"
], ],
"type": "string", "type": "string",
"description": "Range interval identifier", "description": "Range interval identifier",
@ -801,9 +813,13 @@
"last_7_days", "last_7_days",
"30_days", "30_days",
"last_30_days", "last_30_days",
"6_months",
"last_6_months",
"12_months", "12_months",
"last_12_months", "last_12_months",
"any" "last_year",
"any",
"all_time"
], ],
"type": "string", "type": "string",
"description": "Interval identifier", "description": "Interval identifier",

View File

@ -430,9 +430,13 @@ paths:
- last_7_days - last_7_days
- 30_days - 30_days
- last_30_days - last_30_days
- 6_months
- last_6_months
- 12_months - 12_months
- last_12_months - last_12_months
- last_year
- any - any
- all_time
in: path in: path
name: interval name: interval
required: true required: true
@ -623,9 +627,13 @@ paths:
- last_7_days - last_7_days
- 30_days - 30_days
- last_30_days - last_30_days
- 6_months
- last_6_months
- 12_months - 12_months
- last_12_months - last_12_months
- last_year
- any - any
- all_time
in: path in: path
name: range name: range
type: string type: string
@ -686,9 +694,13 @@ paths:
- last_7_days - last_7_days
- 30_days - 30_days
- last_30_days - last_30_days
- 6_months
- last_6_months
- 12_months - 12_months
- last_12_months - last_12_months
- last_year
- any - any
- all_time
in: query in: query
name: range name: range
type: string type: string
@ -925,9 +937,13 @@ paths:
- last_7_days - last_7_days
- 30_days - 30_days
- last_30_days - last_30_days
- 6_months
- last_6_months
- 12_months - 12_months
- last_12_months - last_12_months
- last_year
- any - any
- all_time
in: query in: query
name: interval name: interval
type: string type: string

View File

@ -60,6 +60,8 @@ func ResolveIntervalTZ(interval *models.IntervalKey, tz *time.Location) (err err
from = now.AddDate(0, 0, -14) from = now.AddDate(0, 0, -14)
case models.IntervalPast30Days: case models.IntervalPast30Days:
from = now.AddDate(0, 0, -30) from = now.AddDate(0, 0, -30)
case models.IntervalPast6Months:
from = now.AddDate(0, -6, 0)
case models.IntervalPast12Months: case models.IntervalPast12Months:
from = now.AddDate(0, -12, 0) from = now.AddDate(0, -12, 0)
case models.IntervalAny: case models.IntervalAny:

View File

@ -14,6 +14,7 @@
<a id="time-option-year" class="submenu-item hover:bg-gray-800 rounded p-1 text-right w-full text-gray-300 px-2 font-semibold text-sm" :href="intervalLink('year')" @click="state.showDropdownTimepicker = !state.showDropdownTimepicker" data-trigger-for="showDropdownTimepicker">This Year</a> <a id="time-option-year" class="submenu-item hover:bg-gray-800 rounded p-1 text-right w-full text-gray-300 px-2 font-semibold text-sm" :href="intervalLink('year')" @click="state.showDropdownTimepicker = !state.showDropdownTimepicker" data-trigger-for="showDropdownTimepicker">This Year</a>
<a id="time-option-last_7_days" class="submenu-item hover:bg-gray-800 rounded p-1 text-right w-full text-gray-300 px-2 font-semibold text-sm" :href="intervalLink('last_7_days')" @click="state.showDropdownTimepicker = !state.showDropdownTimepicker" data-trigger-for="showDropdownTimepicker">Past 7 Days</a> <a id="time-option-last_7_days" class="submenu-item hover:bg-gray-800 rounded p-1 text-right w-full text-gray-300 px-2 font-semibold text-sm" :href="intervalLink('last_7_days')" @click="state.showDropdownTimepicker = !state.showDropdownTimepicker" data-trigger-for="showDropdownTimepicker">Past 7 Days</a>
<a id="time-option-last_30_days" class="submenu-item hover:bg-gray-800 rounded p-1 text-right w-full text-gray-300 px-2 font-semibold text-sm" :href="intervalLink('last_30_days')" @click="state.showDropdownTimepicker = !state.showDropdownTimepicker" data-trigger-for="showDropdownTimepicker">Past 30 Days</a> <a id="time-option-last_30_days" class="submenu-item hover:bg-gray-800 rounded p-1 text-right w-full text-gray-300 px-2 font-semibold text-sm" :href="intervalLink('last_30_days')" @click="state.showDropdownTimepicker = !state.showDropdownTimepicker" data-trigger-for="showDropdownTimepicker">Past 30 Days</a>
<a id="time-option-last_6_months" class="submenu-item hover:bg-gray-800 rounded p-1 text-right w-full text-gray-300 px-2 font-semibold text-sm" :href="intervalLink('last_6_months')" @click="state.showDropdownTimepicker = !state.showDropdownTimepicker" data-trigger-for="showDropdownTimepicker">Past 6 Months</a>
<a id="time-option-last_12_months" class="submenu-item hover:bg-gray-800 rounded p-1 text-right w-full text-gray-300 px-2 font-semibold text-sm" :href="intervalLink('last_12_months')" @click="state.showDropdownTimepicker = !state.showDropdownTimepicker" data-trigger-for="showDropdownTimepicker">Past 12 Months</a> <a id="time-option-last_12_months" class="submenu-item hover:bg-gray-800 rounded p-1 text-right w-full text-gray-300 px-2 font-semibold text-sm" :href="intervalLink('last_12_months')" @click="state.showDropdownTimepicker = !state.showDropdownTimepicker" data-trigger-for="showDropdownTimepicker">Past 12 Months</a>
<a id="time-option-any" class="submenu-item hover:bg-gray-800 rounded p-1 text-right w-full text-gray-300 px-2 font-semibold text-sm" :href="intervalLink('any')" @click="state.showDropdownTimepicker = !state.showDropdownTimepicker" data-trigger-for="showDropdownTimepicker">All Time</a> <a id="time-option-any" class="submenu-item hover:bg-gray-800 rounded p-1 text-right w-full text-gray-300 px-2 font-semibold text-sm" :href="intervalLink('any')" @click="state.showDropdownTimepicker = !state.showDropdownTimepicker" data-trigger-for="showDropdownTimepicker">All Time</a>
<hr class="my-2"> <hr class="my-2">