Added concurrent sync, added search page. Other small changes
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"music-server/pkg/models"
|
||||
"os"
|
||||
@@ -9,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
func InsertSongInList(song models.SongListData) {
|
||||
err := pool.QueryRow(context.Background(),
|
||||
_, err := dbpool.Exec(ctx,
|
||||
`INSERT INTO song_list (match_date, match_id, song_no, game_name, song_name) VALUES ($1, $2, $3, $4, $5)`,
|
||||
song.MatchDate, song.MatchId, song.SongNo, song.GameName, song.SongName)
|
||||
if err != nil {
|
||||
@@ -18,12 +17,14 @@ func InsertSongInList(song models.SongListData) {
|
||||
}
|
||||
|
||||
func GetSongList(matchId int) []models.SongListData {
|
||||
rows, err := pool.Query(context.Background(),
|
||||
rows, err := dbpool.Query(ctx,
|
||||
"SELECT match_date, match_id, song_no, game_name, song_name "+
|
||||
"FROM song_list WHERE match_date = $1"+
|
||||
"ORDER BY song_no DESC", matchId)
|
||||
if err != nil {
|
||||
_, _ = fmt.Fprintf(os.Stderr, "QueryRow failed: %v\n", err)
|
||||
if compareError.Error() != err.Error() {
|
||||
_, _ = fmt.Fprintf(os.Stderr, "QueryRow failed: %v\n", err)
|
||||
}
|
||||
}
|
||||
var songList []models.SongListData
|
||||
for rows.Next() {
|
||||
|
||||
Reference in New Issue
Block a user