add config
This commit is contained in:
@@ -56,7 +56,7 @@ func (as ConcertService) CheckAndUpdateConcerts(ctx context.Context) []model.Con
|
||||
return forInsert
|
||||
}
|
||||
|
||||
func scrapeData(ctx context.Context) *[]model.ConcertModel {
|
||||
func scrapeData(_ context.Context) *[]model.ConcertModel {
|
||||
c := colly.NewCollector()
|
||||
concerts := new([]model.ConcertModel)
|
||||
|
||||
@@ -97,19 +97,16 @@ func scrapeData(ctx context.Context) *[]model.ConcertModel {
|
||||
|
||||
func concertKey(concert model.ConcertModel) string {
|
||||
cc := concert.Name + (time.Time)(concert.StartDate).Format("2006-01-02")
|
||||
fmt.Println(cc)
|
||||
return cc
|
||||
}
|
||||
|
||||
func partitionConcerts(previous, current []model.ConcertModel) (newConcerts, deletedConcerts, unchangedConcerts []model.ConcertModel) {
|
||||
// Create a map of previous concerts for quick lookup
|
||||
fmt.Println("Previous concerts\n")
|
||||
previousMap := make(map[string]model.ConcertModel)
|
||||
for _, concert := range previous {
|
||||
previousMap[concertKey(concert)] = concert
|
||||
}
|
||||
|
||||
fmt.Println("New concerts\n")
|
||||
// Create a map of current concerts for quick lookup
|
||||
currentMap := make(map[string]model.ConcertModel)
|
||||
for _, concert := range current {
|
||||
@@ -122,7 +119,6 @@ func partitionConcerts(previous, current []model.ConcertModel) (newConcerts, del
|
||||
unchangedConcerts = append(unchangedConcerts, concert)
|
||||
} else {
|
||||
newConcerts = append(newConcerts, concert)
|
||||
fmt.Printf("New concert %s\n", concert.Name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +126,6 @@ func partitionConcerts(previous, current []model.ConcertModel) (newConcerts, del
|
||||
for _, concert := range previous {
|
||||
if _, exists := currentMap[concertKey(concert)]; !exists {
|
||||
deletedConcerts = append(deletedConcerts, concert)
|
||||
fmt.Printf("Deleted concert %s\n", concert.Name)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user