return more child counts and format sql

This commit is contained in:
sentriz
2020-02-21 00:00:43 +00:00
parent 13d61db339
commit b677af43f0
32 changed files with 671 additions and 504 deletions

View File

@@ -56,7 +56,7 @@ func (c *Controller) ServeHome(r *http.Request) *Response {
// ** begin playlists box
user := r.Context().Value(CtxUser).(*db.User)
c.DB.
Where("user_id = ?", user.ID).
Where("user_id=?", user.ID).
Limit(20).
Find(&data.Playlists)
//

View File

@@ -8,6 +8,7 @@ import (
"github.com/jinzhu/gorm"
"github.com/pkg/errors"
"senan.xyz/g/gonic/db"
)
@@ -18,9 +19,9 @@ func playlistParseLine(c *Controller, path string) (int, error) {
var track db.Track
query := c.DB.Raw(`
SELECT tracks.id FROM TRACKS
JOIN albums ON tracks.album_id = albums.id
WHERE (? || '/' || albums.left_path || albums.right_path || '/' || tracks.filename) = ?
`, c.MusicPath, path)
JOIN albums ON tracks.album_id=albums.id
WHERE (? || '/' || albums.left_path || albums.right_path || '/' || tracks.filename)=?`,
c.MusicPath, path)
err := query.First(&track).Error
switch {
case gorm.IsRecordNotFoundError(err):