Skip to content

Commit

Permalink
add new renewal
Browse files Browse the repository at this point in the history
  • Loading branch information
idprm committed Oct 17, 2024
1 parent 01ff20e commit f6cda14
Showing 1 changed file with 3 additions and 57 deletions.
60 changes: 3 additions & 57 deletions cmd/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"encoding/json"
"log"
"time"

"github.com/idprm/go-football-alert/internal/domain/entity"
Expand Down Expand Up @@ -61,10 +62,11 @@ var publisherRenewalCmd = &cobra.Command{
/**
* Looping schedule per 10 minutes
*/
timeDuration := time.Duration(10)
timeDuration := time.Duration(1)

for {

log.Println("xxx")
go func() {
populateRenewal(db, rmq)
}()
Expand Down Expand Up @@ -122,62 +124,6 @@ var publisherRetryCmd = &cobra.Command{
},
}

var publisherPredictionWinCmd = &cobra.Command{
Use: "pub_predict_win",
Short: "Publisher Predict Win CLI",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
/**
* connect mysql
*/
db, err := connectDb()
if err != nil {
panic(err)
}

/**
* connect rabbitmq
*/
rmq, err := connectRabbitMq()
if err != nil {
panic(err)
}

/**
* SETUP CHANNEL
*/
rmq.SetUpChannel(RMQ_EXCHANGE_TYPE, true, RMQ_PREDICT_WIN_EXCHANGE, true, RMQ_PREDICT_WIN_QUEUE)

/**
* Looping schedule
*/
timeDuration := time.Duration(1)

for {
timeNow := time.Now().Format("15:04")

scheduleRepo := repository.NewScheduleRepository(db)
scheduleService := services.NewScheduleService(scheduleRepo)

if scheduleService.IsUnlocked(ACT_PREDICT_WIN, timeNow) {

scheduleService.UpdateLocked(
&entity.Schedule{
Name: ACT_PREDICT_WIN,
},
)

go func() {
populatePredictWin(db, rmq)
}()
}

time.Sleep(timeDuration * time.Minute)

}
},
}

var publisherPronosticCmd = &cobra.Command{
Use: "pub_pronostic",
Short: "Publisher Pronostic CLI",
Expand Down

0 comments on commit f6cda14

Please sign in to comment.