mirror of https://github.com/status-im/fathom.git
use correct groupby parameter for aggregated stats
This commit is contained in:
parent
624e1f353a
commit
8ed076dd02
|
@ -30,7 +30,7 @@ func UpdatePageStats(s *models.PageStats) error {
|
|||
|
||||
func GetAggregatedPageStats(startDate time.Time, endDate time.Time, limit int) ([]*models.PageStats, error) {
|
||||
var result []*models.PageStats
|
||||
query := dbx.Rebind(`SELECT hostname, pathname, SUM(pageviews) AS pageviews, SUM(visitors) AS visitors, SUM(entries) AS entries, ROUND(AVG(bounce_rate), 0) AS bounce_rate FROM daily_page_stats WHERE date >= ? AND date <= ? GROUP BY hostname, pathname, pageviews, visitors, entries, bounce_rate ORDER BY pageviews DESC LIMIT ?`)
|
||||
query := dbx.Rebind(`SELECT hostname, pathname, SUM(pageviews) AS pageviews, SUM(visitors) AS visitors, SUM(entries) AS entries, ROUND(AVG(bounce_rate), 0) AS bounce_rate FROM daily_page_stats WHERE date >= ? AND date <= ? GROUP BY hostname, pathname ORDER BY pageviews DESC LIMIT ?`)
|
||||
err := dbx.Select(&result, query, startDate.Format("2006-01-02"), endDate.Format("2006-01-02"), limit)
|
||||
return result, err
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ func UpdateReferrerStats(s *models.ReferrerStats) error {
|
|||
|
||||
func GetAggregatedReferrerStats(startDate time.Time, endDate time.Time, limit int) ([]*models.ReferrerStats, error) {
|
||||
var result []*models.ReferrerStats
|
||||
query := dbx.Rebind(`SELECT url, SUM(visitors) AS visitors, SUM(pageviews) AS pageviews FROM daily_referrer_stats WHERE date >= ? AND date <= ? GROUP BY url, visitors, pageviews ORDER BY pageviews DESC LIMIT ?`)
|
||||
query := dbx.Rebind(`SELECT url, SUM(visitors) AS visitors, SUM(pageviews) AS pageviews FROM daily_referrer_stats WHERE date >= ? AND date <= ? GROUP BY url ORDER BY pageviews DESC LIMIT ?`)
|
||||
err := dbx.Select(&result, query, startDate.Format("2006-01-02"), endDate.Format("2006-01-02"), limit)
|
||||
return result, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue