Skip to content

Commit b11d705

Browse files
committed
fix: processing
1 parent 8e128a6 commit b11d705

File tree

2 files changed

+4
-21
lines changed

2 files changed

+4
-21
lines changed

backend/pkd/gasstation/gsbaserepo.go

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func findGasPricesByTimeframe(postCodeGasStationsMap *map[string][]gsmodel.GasSt
121121
}
122122
}
123123
//log.Printf("gasStationIds: %v", len(gasStationIds))
124-
gasPrices := FindPricesByStidsDistinct(&gasStationIds, 0, timeframe)
124+
gasPrices := FindPricesByStids(&gasStationIds, 0, timeframe)
125125
return gasPrices
126126
}
127127

@@ -135,9 +135,8 @@ func createPostCodeGasStationsMap() map[string][]gsmodel.GasStation {
135135
return postCodeGasStationsMap
136136
}
137137

138-
func findPricesByStids(stids *[]string, resultLimit int, distinct bool, timeframe TimeFrame) []gsmodel.GasPrice {
138+
func findPricesByStids(stids *[]string, resultLimit int, timeframe TimeFrame) []gsmodel.GasPrice {
139139
var myGasPrices []gsmodel.GasPrice
140-
gasStationidGasPriceMap := make(map[string]gsmodel.GasPrice)
141140
var myTimeFrame time.Time
142141
if timeframe == Day {
143142
myTimeFrame = time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, -1).Round(time.Hour)
@@ -157,18 +156,7 @@ func findPricesByStids(stids *[]string, resultLimit int, distinct bool, timefram
157156
}
158157
myQuery.Find(&values)
159158
//log.Printf("%v", values)
160-
if distinct {
161-
for _, value := range values {
162-
if myValue, ok := gasStationidGasPriceMap[value.GasStationID]; !ok || myValue.Date.Before(value.Date) {
163-
gasStationidGasPriceMap[value.GasStationID] = value
164-
}
165-
}
166-
for _, myGasPrice := range gasStationidGasPriceMap {
167-
myGasPrices = append(myGasPrices, myGasPrice)
168-
}
169-
} else {
170-
myGasPrices = append(myGasPrices, values...)
171-
}
159+
myGasPrices = append(myGasPrices, values...)
172160
}
173161
return nil
174162
})

backend/pkd/gasstation/gsrepo.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -379,12 +379,7 @@ func FindById(id string) gsmodel.GasStation {
379379
}
380380

381381
func FindPricesByStids(stids *[]string, resultLimit int, timeframe TimeFrame) []gsmodel.GasPrice {
382-
myGasPrice := findPricesByStids(stids, resultLimit, false, timeframe)
383-
return myGasPrice
384-
}
385-
386-
func FindPricesByStidsDistinct(stids *[]string, resultLimit int, timeframe TimeFrame) []gsmodel.GasPrice {
387-
myGasPrice := findPricesByStids(stids, resultLimit, true, timeframe)
382+
myGasPrice := findPricesByStids(stids, resultLimit, timeframe)
388383
return myGasPrice
389384
}
390385

0 commit comments

Comments
 (0)