This commit is contained in:
2021-10-29 10:09:55 -05:00
parent d105e88992
commit 2116778276
10 changed files with 47 additions and 44 deletions

26
runner/get_top.go Normal file
View File

@@ -0,0 +1,26 @@
package runner
import (
_ "embed"
"fmt"
"time"
)
//go:embed sql/get_top.sql
var get_top string
func (r *Runner) GetTop() []Data {
//Get Current Days
current_day := time.Now()
year := current_day.Format("2006")
previous_month := current_day.AddDate(0, -1, 0).Format("01")
two_previous_month := current_day.AddDate(0, -2, 0).Format("01")
four_previous_month := current_day.AddDate(0, -4, 0).Format("01")
query_string := fmt.Sprintf(get_top, year, previous_month, four_previous_month, two_previous_month)
var top []Data
err := r.db.Select(&top, query_string)
checkErr(err)
return top
}