refactor: remove roblox code
unused
This commit is contained in:
parent
723813839d
commit
57816301f9
7 changed files with 1 additions and 85 deletions
|
|
@ -14,7 +14,4 @@ GITHUB_PROJECTS="trafficlunar/options-profiles,trafficlunar/blockmatic"
|
|||
GITHUB_TOKEN="API_KEY_GOES_HERE"
|
||||
|
||||
# The password for the computer WebSocket
|
||||
WEBSOCKET_PASSWORD="PASSWORD_GOES_HERE"
|
||||
|
||||
# Roblox
|
||||
GROWAROBLOXIAN_UNIVERSE_ID=7778892933
|
||||
WEBSOCKET_PASSWORD="PASSWORD_GOES_HERE"
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"api/internal/worker"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func HandleGetGrowARobloxianLikesCount(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(worker.GrowARobloxianLikes)
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
package model
|
||||
|
||||
type RobloxGameVotesAPI struct {
|
||||
Data []struct {
|
||||
Id int `json:"id"`
|
||||
Upvotes int `json:"upVotes"`
|
||||
Downvotes int `json:"downVotes"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
|
@ -74,7 +74,6 @@ func NewRouter() {
|
|||
r.Get("/song", handler.HandleGetCurrentlyPlaying)
|
||||
r.Get("/projects", handler.HandleGetProjects)
|
||||
r.Get("/computer", handler.HandleComputerGraphData)
|
||||
r.Get("/roblox/grow-a-robloxian/likes", handler.HandleGetGrowARobloxianLikesCount)
|
||||
})
|
||||
|
||||
r.Get("/computer/ws", handler.HandleComputerWebSocket)
|
||||
|
|
|
|||
|
|
@ -1,40 +0,0 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"api/internal/model"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
func GetRobloxGrowARobloxianLikesCount() int {
|
||||
url := fmt.Sprintf("https://games.roblox.com/v1/games/votes?universeIds=%s", os.Getenv("GROWAROBLOXIAN_UNIVERSE_ID"))
|
||||
res, err := http.Get(url)
|
||||
if err != nil {
|
||||
slog.Error("Error requesting Roblox votes API", slog.Any("error", err))
|
||||
return 0
|
||||
}
|
||||
|
||||
body, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
slog.Error("Error reading body", slog.Any("error", err))
|
||||
return 0
|
||||
}
|
||||
|
||||
var apiData model.RobloxGameVotesAPI
|
||||
err = json.Unmarshal(body, &apiData)
|
||||
if err != nil {
|
||||
slog.Error("Error unmarshalling JSON", slog.Any("error", err))
|
||||
return 0
|
||||
}
|
||||
|
||||
if apiData.Data == nil {
|
||||
slog.Warn("No data returned from Roblox votes API")
|
||||
return 0
|
||||
}
|
||||
|
||||
return apiData.Data[0].Upvotes
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
package worker
|
||||
|
||||
import (
|
||||
"api/internal/service"
|
||||
"log/slog"
|
||||
"time"
|
||||
)
|
||||
|
||||
var GrowARobloxianLikes int
|
||||
|
||||
func StartRobloxWorker() {
|
||||
slog.Info("Starting Roblox worker...")
|
||||
GrowARobloxianLikes = service.GetRobloxGrowARobloxianLikesCount()
|
||||
|
||||
for range time.Tick(1 * time.Minute) {
|
||||
GrowARobloxianLikes = service.GetRobloxGrowARobloxianLikesCount()
|
||||
}
|
||||
}
|
||||
|
|
@ -5,5 +5,4 @@ func StartWorkers() {
|
|||
go StartLastFMWorker()
|
||||
go StartGitHubWorker()
|
||||
go StartComputerWorker()
|
||||
go StartRobloxWorker()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue