Commit af470f28 authored by Rafael's avatar Rafael

feature: insert on Redis number of visits per day

parent 7386665c
Pipeline #20657215 passed with stage
......@@ -201,9 +201,19 @@ func GetPost(slug string) map[string]interface{} {
singlepost["album"] = albuns[singlepost["id"].(string)]
}
go incrementPostVisit(slug)
return singlepost
}
func incrementPostVisit(slug string) {
client := database.DBRedisCon
currentTime := time.Now().Local()
key := "post_views:" + currentTime.Format("20060102")
client.ZIncrBy(key, 1, slug)
}
// GetPosts return the posts asked
func GetPosts(category string, page int32) []map[string]interface{} {
db := database.DBCon
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment