package api

import (
	"music-server/pkg/server"
	"net/http"

	"github.com/gin-gonic/gin"
)

type Sync struct {
}

func NewSync() *Sync {
	return &Sync{}
}

func (s *Sync) SyncGames(ctx *gin.Context) {
	server.SyncGames()
	server.Reset()
	ctx.JSON(http.StatusOK, "Games are synced")
}

func (s *Sync) SyncGamesQuick(ctx *gin.Context) {
	server.SyncGamesQuick()
	server.Reset()
	ctx.JSON(http.StatusOK, "Games are synced")
}

func (s *Sync) SyncGamesNew(ctx *gin.Context) {
	response := server.SyncGamesNew()
	server.Reset()
	ctx.JSON(http.StatusOK, response)
}

func (s *Sync) ResetGames(ctx *gin.Context) {
	server.ResetDB()
	ctx.JSON(http.StatusOK, "Games and songs are deleted from the database")
}
