diff options
| author | Fuwn <[email protected]> | 2021-07-17 10:59:45 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-07-17 10:59:45 +0000 |
| commit | feecffd260cf00ba5d55b09894979ed9e66604e6 (patch) | |
| tree | 4c9f00692eecf3c9bd828de63cbb24964368ce7d | |
| parent | feat(route): blog handler for multi-blog support (diff) | |
| download | space-feecffd260cf00ba5d55b09894979ed9e66604e6.tar.xz space-feecffd260cf00ba5d55b09894979ed9e66604e6.zip | |
refactor(route): move hit ticker to db layer
| -rw-r--r-- | pkg/database/database.go | 2 | ||||
| -rw-r--r-- | route.go | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/pkg/database/database.go b/pkg/database/database.go index 9d14fa9..8aa658c 100644 --- a/pkg/database/database.go +++ b/pkg/database/database.go @@ -36,7 +36,7 @@ func Get(path string) int { return 0 } - return hit.Count + return hit.Count + 1 } func Create(path string) { @@ -21,7 +21,7 @@ func createRoute(route string, template string, content string) { return c.Render(template, IndexTemplate{ Content: GetContent(content), Quote: utilities.GetRandomQuote(), - Hits: database.Get(route) + 1, + Hits: database.Get(route), // SystemInfo: fmt.Sprintf("Host: %s %s, Uptime: %d seconds, Routes: %d", strings.Title(hostInformation.Platform), strings.Title(hostInformation.OS), int64(time.Since(startTime).Seconds()), len(g.Routes())), Copyright: utilities.GetCopyright(), }) @@ -36,7 +36,7 @@ func createErrorRoute(route string, template string, content string, err string) Error: err, Content: GetContent(content), Quote: utilities.GetRandomQuote(), - Hits: database.Get(route) + 1, + Hits: database.Get(route), Copyright: utilities.GetCopyright(), }) }) @@ -59,7 +59,7 @@ func createBlogHandler(route string) { return c.Render("default.gmi", IndexTemplate{ Content: blogList, Quote: utilities.GetRandomQuote(), - Hits: database.Get(route) + 1, + Hits: database.Get(route), Copyright: utilities.GetCopyright(), }) }) @@ -87,7 +87,7 @@ func createBlogRoute(baseRoute string, postPath string, name string) { return c.Render("default.gmi", IndexTemplate{ Content: files, Quote: utilities.GetRandomQuote(), - Hits: database.Get(baseRoute) + 1, + Hits: database.Get(baseRoute), Copyright: utilities.GetCopyright(), }) }) |