Skip to content

Commit

Permalink
fix poll gh
Browse files Browse the repository at this point in the history
  • Loading branch information
stelzo committed Jan 14, 2025
1 parent e6ee4e1 commit b35c559
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 41 deletions.
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ toolchain go1.23.0
require (
github.com/PuerkitoBio/goquery v1.10.1
github.com/charmbracelet/log v0.4.0
github.com/dofusdude/dodugo v1.0.0-rc.8
github.com/dofusdude/dodumap v0.6.3
github.com/google/go-github/v67 v67.0.0
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8
Expand All @@ -26,7 +25,7 @@ require (
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/muesli/termenv v0.15.2 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/stretchr/testify v1.10.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/sys v0.29.0 // indirect
gopkg.in/validator.v2 v2.0.1 // indirect
)
10 changes: 0 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ github.com/charmbracelet/x/ansi v0.6.0 h1:qOznutrb93gx9oMiGf7caF7bqqubh6YIM0SWKy
github.com/charmbracelet/x/ansi v0.6.0/go.mod h1:KBUFw1la39nl0dLl10l5ORDAqGXaeurTQmwyyVKse/Q=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dofusdude/dodugo v1.0.0-rc.8 h1:C3LCiBag8BaFzMEJ7xnwur0aXAVGMwPH78T3eqt88TQ=
github.com/dofusdude/dodugo v1.0.0-rc.8/go.mod h1:R/MZWCsB/+GpFctfckhOWmqpCMgmGkB+YC3N3TS3n6Y=
github.com/dofusdude/dodumap v0.6.3 h1:KTaW+vduvHUl15oWQfWnXm0iwzyFyzItCPGathbsofM=
github.com/dofusdude/dodumap v0.6.3/go.mod h1:51KG2eMd02UJnXErOubAukVftYuJproDHqJcbIHSzIE=
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
Expand All @@ -27,10 +25,6 @@ github.com/google/go-github/v67 v67.0.0 h1:g11NDAmfaBaCO8qYdI9fsmbaRipHNWRIU/2YG
github.com/google/go-github/v67 v67.0.0/go.mod h1:zH3K7BxjFndr9QSeFibx4lTKkYS3K9nDanoI1NjaOtY=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
Expand Down Expand Up @@ -118,9 +112,5 @@ golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/validator.v2 v2.0.1 h1:xF0KWyGWXm/LM2G1TrEjqOu4pa6coO9AlWSf3msVfDY=
gopkg.in/validator.v2 v2.0.1/go.mod h1:lIUZBlB3Im4s/eYp39Ry/wkR02yOPhZ9IwIRBjuPuG8=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
37 changes: 8 additions & 29 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (

"github.com/PuerkitoBio/goquery"
"github.com/charmbracelet/log"
"github.com/dofusdude/dodugo"
mapping "github.com/dofusdude/dodumap"
"github.com/google/go-github/v67/github"
"golang.org/x/exp/rand"
Expand Down Expand Up @@ -334,21 +333,6 @@ func saveLocalVersion(version string, workdir string) error {
}

func updateChan(ctx context.Context, interval time.Duration, update chan string, workdir string, readyForUpdate chan bool) {
serverUrl := "https://api.dofusdu.de"
game := "dofus3"
cfg := &dodugo.Configuration{
DefaultHeader: make(map[string]string),
UserAgent: "dofusdude/alm-dates",
Debug: false,
Servers: dodugo.ServerConfigurations{
{
URL: serverUrl,
Description: "API",
},
},
OperationServers: map[string]dodugo.ServerConfigurations{},
}

timer := time.NewTicker(interval)

isReady := true
Expand All @@ -364,33 +348,28 @@ func updateChan(ctx context.Context, interval time.Duration, update chan string,
continue
}

var dodugoClient = dodugo.NewAPIClient(cfg)

version, http, err := dodugoClient.MetaAPI.GetMetaVersion(ctx, game).Execute()
ghclient := github.NewClient(nil)
repRel, _, err := ghclient.Repositories.GetLatestRelease(context.Background(), DataRepoOwner, DataRepoName)
if err != nil {
log.Fatal("error getting meta version: ", err)
log.Fatal("error getting latest gh release: ", err)
return
}

if http != nil && http.StatusCode != 200 {
log.Fatal("error getting meta version", "status", http.Status)
return
}
currentVersion := repRel.GetTagName()

currentApiVersion := version.GetVersion()
localVersion, err := loadLocalVersion(workdir)
if err != nil {
log.Fatal("error loading local version: ", err)
return
}

if currentApiVersion != localVersion {
err = saveLocalVersion(*version.Version, workdir)
if currentVersion != localVersion {
err = saveLocalVersion(currentVersion, workdir)
if err != nil {
log.Fatal("error saving local version: ", err)
return
}
update <- currentApiVersion
update <- currentVersion
}
}
}
Expand Down Expand Up @@ -442,7 +421,7 @@ func main() {

pollIntervalStr := os.Getenv("POLLING_INTERVAL")
if pollIntervalStr == "" {
pollIntervalStr = "1m"
pollIntervalStr = "5m"
}

endDurationStr := os.Getenv("END_DURATION")
Expand Down

0 comments on commit b35c559

Please sign in to comment.