-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
41 lines (38 loc) · 860 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"fmt"
"sync"
"time"
"github.com/matisidler/smiles-bot/logic"
"github.com/matisidler/smiles-bot/models"
)
func main() {
start := time.Now()
var wg sync.WaitGroup
var locker sync.Mutex
days := []string{"04", "05", "11", "12", "18", "19", "25", "26", "28"}
var monthList []models.Day
for i := 0; i < 9; i++ {
wg.Add(1)
go func(index int) {
defer wg.Done()
list, err := logic.GetRequest("2022", "10", days[index], "EZE", "CUN", index != 0 && index%2 != 0)
if err != nil {
fmt.Println(err)
return
}
locker.Lock()
monthList = append(monthList, list...)
locker.Unlock()
}(i)
}
wg.Wait()
monthList = logic.Remove0Values(monthList)
logic.LookForBestPrices(monthList)
if len(monthList) < 10 {
fmt.Println(monthList)
return
}
fmt.Println(monthList[0:10])
fmt.Println(time.Since(start))
}