ranking.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Package query contains database queries for the jamtrack application.
  2. package query
  3. import (
  4. "github.com/pocketbase/dbx"
  5. "github.com/pocketbase/pocketbase/core"
  6. )
  7. // SongRank holds the aggregated play statistics for a single song.
  8. type SongRank struct {
  9. ID string `db:"id"`
  10. Artist string `db:"artist"`
  11. Title string `db:"title"`
  12. PlayedCount int `db:"played_count"`
  13. ProposedCount int `db:"proposed_count"`
  14. }
  15. // FetchRanking returns songs ordered by play frequency (played_count desc,
  16. // proposed_count desc). If locationID is non-empty the results are filtered
  17. // to jams at that location.
  18. func FetchRanking(app core.App, locationID string) ([]SongRank, error) {
  19. var rows []SongRank
  20. if locationID != "" {
  21. err := app.DB().
  22. NewQuery(`
  23. SELECT s.id, s.artist, s.title,
  24. COALESCE(SUM(sl.played), 0) AS played_count,
  25. COUNT(sl.id) AS proposed_count
  26. FROM setlist sl
  27. JOIN songs s ON s.id = sl.song
  28. JOIN jams j ON j.id = sl.jam
  29. WHERE j.location = {:location}
  30. GROUP BY s.id
  31. ORDER BY played_count DESC, proposed_count DESC
  32. `).
  33. Bind(dbx.Params{"location": locationID}).
  34. All(&rows)
  35. return rows, err
  36. }
  37. err := app.DB().
  38. NewQuery(`
  39. SELECT s.id, s.artist, s.title,
  40. COALESCE(SUM(sl.played), 0) AS played_count,
  41. COUNT(sl.id) AS proposed_count
  42. FROM setlist sl
  43. JOIN songs s ON s.id = sl.song
  44. GROUP BY s.id
  45. ORDER BY played_count DESC, proposed_count DESC
  46. `).
  47. All(&rows)
  48. return rows, err
  49. }
PANIC: session(release): write data/sessions/3/6/364dfe54fc37b373: no space left on device

PANIC

session(release): write data/sessions/3/6/364dfe54fc37b373: no space left on device
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/session@v1.0.3/session.go:204 (0xb13e07)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/context.go:80 (0x967b75)
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/inject@v0.0.0-20200308113650-138e5925c53b/inject.go:157 (0x9512ee)
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/inject@v0.0.0-20200308113650-138e5925c53b/inject.go:135 (0x951205)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/context.go:124 (0x967cc4)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/context.go:114 (0x967bf6)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/recovery.go:161 (0x15baec4)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/logger.go:40 (0x96b257)
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/inject@v0.0.0-20200308113650-138e5925c53b/inject.go:157 (0x9512ee)
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/inject@v0.0.0-20200308113650-138e5925c53b/inject.go:135 (0x951205)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/context.go:124 (0x967cc4)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/router.go:187 (0x972959)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/router.go:304 (0x973a01)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/macaron.go:218 (0x96c572)
/my/cache/.heroku/go/go1.26.3/go/src/net/http/server.go:3311 (0x85a5cd)
/my/cache/.heroku/go/go1.26.3/go/src/net/http/server.go:2073 (0x837f6f)
/my/cache/.heroku/go/go1.26.3/go/src/runtime/asm_amd64.s:1771 (0x493380)