27 lines
602 B
Go
27 lines
602 B
Go
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
|
|
}
|