Skip to content

Commit

Permalink
wrap ready
Browse files Browse the repository at this point in the history
  • Loading branch information
stelzo committed Dec 7, 2024
1 parent 28ff71b commit 794992f
Showing 1 changed file with 42 additions and 40 deletions.
82 changes: 42 additions & 40 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,60 +455,62 @@ func main() {
return
case version := <-update:

// signal that we are ready for the next update to start
readyForUpdate <- false
defer func() {
readyForUpdate <- true
log.Info("ready for next update")
}()

log.Info("update detected", "version", version)

almData, err := loadAlmanaxData(version)
if err != nil {
log.Fatal("error loading almanax data: ", "error", err)
}
func() {
defer func() {
readyForUpdate <- true
log.Info("ready for next update")
}()

almData, err := loadAlmanaxData(version)
if err != nil {
log.Fatal("error loading almanax data: ", "error", err)
}

// map the data
today := time.Now()
inYear := today.Add(endDuration)
fromDate := today.Format("2006-01-02")
toDate := inYear.Format("2006-01-02")
// map the data
today := time.Now()
inYear := today.Add(endDuration)
fromDate := today.Format("2006-01-02")
toDate := inYear.Format("2006-01-02")

dateRange := createDateRange(fromDate, toDate)
dateRange := createDateRange(fromDate, toDate)

if len(almData[0].Days) != 0 && almData[0].Days[0] != "" {
log.Info("data already mapped, skipping", "version", version)
continue
}
if len(almData[0].Days) != 0 && almData[0].Days[0] != "" {
log.Info("data already mapped, skipping", "version", version)
return
}

log.Info("Mapping...")
start := time.Now()
log.Info("Mapping...")
start := time.Now()

for _, date := range dateRange {
offeringReceiverKrozmoz := getAlmOfferingReceiver(date)
for _, date := range dateRange {
offeringReceiverKrozmoz := getAlmOfferingReceiver(date)

found := false
for i, almDataLocal := range almData {
if almDataLocal.OfferingReceiver == offeringReceiverKrozmoz {
found = true
almData[i].Days = append(almData[i].Days, date)
break
found := false
for i, almDataLocal := range almData {
if almDataLocal.OfferingReceiver == offeringReceiverKrozmoz {
found = true
almData[i].Days = append(almData[i].Days, date)
break
}
}
}
if !found {
log.Fatal("could not find offering receiver: ", offeringReceiverKrozmoz)
if !found {
log.Fatal("could not find offering receiver: ", offeringReceiverKrozmoz)
}

time.Sleep(time.Duration(rand.Intn(2)+1) * time.Second)
}

time.Sleep(time.Duration(rand.Intn(2)+1) * time.Second)
}
log.Info("Mapping done", "duration", time.Since(start))

log.Info("Mapping done", "duration", time.Since(start))
err = updateAlmanaxRelease(almData, version, ghAuthKey)
if err != nil {
log.Fatal("error updating almanax release: ", err)
}
}()

err = updateAlmanaxRelease(almData, version, ghAuthKey)
if err != nil {
log.Fatal("error updating almanax release: ", err)
}
}
}
}

0 comments on commit 794992f

Please sign in to comment.