aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-07-17 10:59:45 +0000
committerFuwn <[email protected]>2021-07-17 10:59:45 +0000
commitfeecffd260cf00ba5d55b09894979ed9e66604e6 (patch)
tree4c9f00692eecf3c9bd828de63cbb24964368ce7d
parentfeat(route): blog handler for multi-blog support (diff)
downloadspace-feecffd260cf00ba5d55b09894979ed9e66604e6.tar.xz
space-feecffd260cf00ba5d55b09894979ed9e66604e6.zip
refactor(route): move hit ticker to db layer
-rw-r--r--pkg/database/database.go2
-rw-r--r--route.go8
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) {
diff --git a/route.go b/route.go
index 8f43a05..81db977 100644
--- a/route.go
+++ b/route.go
@@ -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(),
})
})