diff --git a/main.go b/main.go index e0c0d74..d92bf54 100644 --- a/main.go +++ b/main.go @@ -247,18 +247,19 @@ func main() { // https://github.com/golang/go/issues/43431 embeddedStatic, _ := fs.Sub(staticFiles, "static") static := conf.ChooseFS("static", embeddedStatic) - fileServer := gzipped.FileServer(fsutils.NewExistsHttpFS( - fsutils.NewExistsFS( - fsutils.NeuteredFileSystem{ - FS: static, - }).WithCache(!config.IsDev()), + + assetsFileServer := gzipped.FileServer(fsutils.NewExistsHttpFS( + fsutils.NewExistsFS(static).WithCache(!config.IsDev()), + )) + staticFileServer := http.FileServer(http.FS( + fsutils.NeuteredFileSystem{FS: static}, )) - router.PathPrefix("/contribute.json").Handler(fileServer) - router.PathPrefix("/assets").Handler(fileServer) - router.PathPrefix("/swagger-ui").Handler(fileServer) + router.PathPrefix("/contribute.json").Handler(staticFileServer) + router.PathPrefix("/assets").Handler(assetsFileServer) + router.PathPrefix("/swagger-ui").Handler(staticFileServer) router.PathPrefix("/docs").Handler( - middlewares.NewFileTypeFilterMiddleware([]string{".go"})(fileServer), + middlewares.NewFileTypeFilterMiddleware([]string{".go"})(staticFileServer), ) // Miscellaneous diff --git a/routes/api/summary.go b/routes/api/summary.go index 47d2131..24555fa 100644 --- a/routes/api/summary.go +++ b/routes/api/summary.go @@ -41,6 +41,12 @@ func (h *SummaryApiHandler) RegisterRoutes(router *mux.Router) { // @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 recompute query bool false "Whether to recompute the summary from raw heartbeat or use cache" +// @Param project query string false "Project to filter by" +// @Param language query string false "Language to filter by" +// @Param editor query string false "Editor to filter by" +// @Param operating_system query string false "OS to filter by" +// @Param machine query string false "Machine to filter by" +// @Param label query string false "Project label to filter by" // @Security ApiKeyAuth // @Success 200 {object} models.Summary // @Router /summary [get] diff --git a/routes/compat/wakatime/v1/stats.go b/routes/compat/wakatime/v1/stats.go index a9e82c5..6d7cccc 100644 --- a/routes/compat/wakatime/v1/stats.go +++ b/routes/compat/wakatime/v1/stats.go @@ -50,6 +50,12 @@ func (h *StatsHandler) RegisterRoutes(router *mux.Router) { // @Produce json // @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 project query string false "Project to filter by" +// @Param language query string false "Language to filter by" +// @Param editor query string false "Editor to filter by" +// @Param operating_system query string false "OS to filter by" +// @Param machine query string false "Machine to filter by" +// @Param label query string false "Project label to filter by" // @Security ApiKeyAuth // @Success 200 {object} v1.StatsViewModel // @Router /compat/wakatime/v1/users/{user}/stats/{range} [get] diff --git a/routes/compat/wakatime/v1/summaries.go b/routes/compat/wakatime/v1/summaries.go index c28c596..9a24eeb 100644 --- a/routes/compat/wakatime/v1/summaries.go +++ b/routes/compat/wakatime/v1/summaries.go @@ -52,6 +52,12 @@ func (h *SummariesHandler) RegisterRoutes(router *mux.Router) { // @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 start query string false "Start date (e.g. '2021-02-07')" // @Param end query string false "End date (e.g. '2021-02-08')" +// @Param project query string false "Project to filter by" +// @Param language query string false "Language to filter by" +// @Param editor query string false "Editor to filter by" +// @Param operating_system query string false "OS to filter by" +// @Param machine query string false "Machine to filter by" +// @Param label query string false "Project label to filter by" // @Security ApiKeyAuth // @Success 200 {object} v1.SummariesViewModel // @Router /compat/wakatime/v1/users/{user}/summaries [get] diff --git a/static/docs/docs.go b/static/docs/docs.go index 2d33ec3..0780cdb 100644 --- a/static/docs/docs.go +++ b/static/docs/docs.go @@ -313,6 +313,42 @@ var doc = `{ "description": "Range interval identifier", "name": "range", "in": "path" + }, + { + "type": "string", + "description": "Project to filter by", + "name": "project", + "in": "query" + }, + { + "type": "string", + "description": "Language to filter by", + "name": "language", + "in": "query" + }, + { + "type": "string", + "description": "Editor to filter by", + "name": "editor", + "in": "query" + }, + { + "type": "string", + "description": "OS to filter by", + "name": "operating_system", + "in": "query" + }, + { + "type": "string", + "description": "Machine to filter by", + "name": "machine", + "in": "query" + }, + { + "type": "string", + "description": "Project label to filter by", + "name": "label", + "in": "query" } ], "responses": { @@ -380,6 +416,42 @@ var doc = `{ "description": "End date (e.g. '2021-02-08')", "name": "end", "in": "query" + }, + { + "type": "string", + "description": "Project to filter by", + "name": "project", + "in": "query" + }, + { + "type": "string", + "description": "Language to filter by", + "name": "language", + "in": "query" + }, + { + "type": "string", + "description": "Editor to filter by", + "name": "editor", + "in": "query" + }, + { + "type": "string", + "description": "OS to filter by", + "name": "operating_system", + "in": "query" + }, + { + "type": "string", + "description": "Machine to filter by", + "name": "machine", + "in": "query" + }, + { + "type": "string", + "description": "Project label to filter by", + "name": "label", + "in": "query" } ], "responses": { @@ -719,6 +791,42 @@ var doc = `{ "description": "Whether to recompute the summary from raw heartbeat or use cache", "name": "recompute", "in": "query" + }, + { + "type": "string", + "description": "Project to filter by", + "name": "project", + "in": "query" + }, + { + "type": "string", + "description": "Language to filter by", + "name": "language", + "in": "query" + }, + { + "type": "string", + "description": "Editor to filter by", + "name": "editor", + "in": "query" + }, + { + "type": "string", + "description": "OS to filter by", + "name": "operating_system", + "in": "query" + }, + { + "type": "string", + "description": "Machine to filter by", + "name": "machine", + "in": "query" + }, + { + "type": "string", + "description": "Project label to filter by", + "name": "label", + "in": "query" } ], "responses": { diff --git a/static/docs/swagger.json b/static/docs/swagger.json index a91d191..b315ad5 100644 --- a/static/docs/swagger.json +++ b/static/docs/swagger.json @@ -298,6 +298,42 @@ "description": "Range interval identifier", "name": "range", "in": "path" + }, + { + "type": "string", + "description": "Project to filter by", + "name": "project", + "in": "query" + }, + { + "type": "string", + "description": "Language to filter by", + "name": "language", + "in": "query" + }, + { + "type": "string", + "description": "Editor to filter by", + "name": "editor", + "in": "query" + }, + { + "type": "string", + "description": "OS to filter by", + "name": "operating_system", + "in": "query" + }, + { + "type": "string", + "description": "Machine to filter by", + "name": "machine", + "in": "query" + }, + { + "type": "string", + "description": "Project label to filter by", + "name": "label", + "in": "query" } ], "responses": { @@ -365,6 +401,42 @@ "description": "End date (e.g. '2021-02-08')", "name": "end", "in": "query" + }, + { + "type": "string", + "description": "Project to filter by", + "name": "project", + "in": "query" + }, + { + "type": "string", + "description": "Language to filter by", + "name": "language", + "in": "query" + }, + { + "type": "string", + "description": "Editor to filter by", + "name": "editor", + "in": "query" + }, + { + "type": "string", + "description": "OS to filter by", + "name": "operating_system", + "in": "query" + }, + { + "type": "string", + "description": "Machine to filter by", + "name": "machine", + "in": "query" + }, + { + "type": "string", + "description": "Project label to filter by", + "name": "label", + "in": "query" } ], "responses": { @@ -704,6 +776,42 @@ "description": "Whether to recompute the summary from raw heartbeat or use cache", "name": "recompute", "in": "query" + }, + { + "type": "string", + "description": "Project to filter by", + "name": "project", + "in": "query" + }, + { + "type": "string", + "description": "Language to filter by", + "name": "language", + "in": "query" + }, + { + "type": "string", + "description": "Editor to filter by", + "name": "editor", + "in": "query" + }, + { + "type": "string", + "description": "OS to filter by", + "name": "operating_system", + "in": "query" + }, + { + "type": "string", + "description": "Machine to filter by", + "name": "machine", + "in": "query" + }, + { + "type": "string", + "description": "Project label to filter by", + "name": "label", + "in": "query" } ], "responses": { diff --git a/static/docs/swagger.yaml b/static/docs/swagger.yaml index f47c0b6..a705287 100644 --- a/static/docs/swagger.yaml +++ b/static/docs/swagger.yaml @@ -536,6 +536,30 @@ paths: in: path name: range type: string + - description: Project to filter by + in: query + name: project + type: string + - description: Language to filter by + in: query + name: language + type: string + - description: Editor to filter by + in: query + name: editor + type: string + - description: OS to filter by + in: query + name: operating_system + type: string + - description: Machine to filter by + in: query + name: machine + type: string + - description: Project label to filter by + in: query + name: label + type: string produces: - application/json responses: @@ -583,6 +607,30 @@ paths: in: query name: end type: string + - description: Project to filter by + in: query + name: project + type: string + - description: Language to filter by + in: query + name: language + type: string + - description: Editor to filter by + in: query + name: editor + type: string + - description: OS to filter by + in: query + name: operating_system + type: string + - description: Machine to filter by + in: query + name: machine + type: string + - description: Project label to filter by + in: query + name: label + type: string produces: - application/json responses: @@ -804,6 +852,30 @@ paths: in: query name: recompute type: boolean + - description: Project to filter by + in: query + name: project + type: string + - description: Language to filter by + in: query + name: language + type: string + - description: Editor to filter by + in: query + name: editor + type: string + - description: OS to filter by + in: query + name: operating_system + type: string + - description: Machine to filter by + in: query + name: machine + type: string + - description: Project label to filter by + in: query + name: label + type: string produces: - application/json responses: