Skip to content

Commit

Permalink
use LIMIT #, OFFSET # syntax for compat across all database drivers. f…
Browse files Browse the repository at this point in the history
…ixes #188
  • Loading branch information
dannyvankooten committed Nov 22, 2018
1 parent 239f880 commit a04307e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/datastore/sqlstore/page_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ func (db *sqlstore) SelectAggregatedPageStats(siteID int64, startDate time.Time,
LEFT JOIN pathnames p ON p.id = s.pathname_id
WHERE site_id = ? AND ts >= ? AND ts <= ?
GROUP BY hostname, pathname
ORDER BY pageviews DESC LIMIT ?, ?`)
err := db.Select(&result, query, siteID, startDate.Format(DATE_FORMAT), endDate.Format(DATE_FORMAT), offset, limit)
ORDER BY pageviews DESC LIMIT ? OFFSET ?`)
err := db.Select(&result, query, siteID, startDate.Format(DATE_FORMAT), endDate.Format(DATE_FORMAT), limit, offset)
return result, err
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/datastore/sqlstore/referrer_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ func (db *sqlstore) SelectAggregatedReferrerStats(siteID int64, startDate time.T
} else {
sql = sql + `GROUP BY COALESCE(NULLIF(groupname, ''), CONCAT(hostname_id, pathname_id) ) `
}
sql = sql + ` ORDER BY pageviews DESC LIMIT ?, ?`
sql = sql + ` ORDER BY pageviews DESC LIMIT ? OFFSET ?`

query := db.Rebind(sql)

err := db.Select(&result, query, siteID, startDate.Format(DATE_FORMAT), endDate.Format(DATE_FORMAT), offset, limit)
err := db.Select(&result, query, siteID, startDate.Format(DATE_FORMAT), endDate.Format(DATE_FORMAT), limit, offset)
return result, mapError(err)
}

Expand Down

0 comments on commit a04307e

Please sign in to comment.