Skip to content

Commit 513dd1f

Browse files
committed
fix: county prices
1 parent e73a473 commit 513dd1f

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

backend/pkd/fileimport/postcodeimport.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func updateCountyStatePrices(plzs []string) {
189189
gasStationStids = append(gasStationStids, myGasStation.ID)
190190
plzGasStation[myGasStation.PostCode] = append(plzGasStation[myGasStation.PostCode], myGasStation)
191191
}
192-
myGasPrices := gasstation.FindPricesByStids(&gasStationStids, 5, gasstation.Month)
192+
myGasPrices := gasstation.FindPricesByStids(&gasStationStids, 5, gasstation.Month, false)
193193
gasStationIdGasPrices := make(map[string][]gsmodel.GasPrice)
194194
for _, myGasPrice := range myGasPrices {
195195
gasStationIdGasPrices[myGasPrice.GasStationID] = append(gasStationIdGasPrices[myGasPrice.GasStationID], myGasPrice)

backend/pkd/gasstation/gsbaserepo.go

+6-3
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 := FindPricesByStids(&gasStationIds, 0, timeframe)
124+
gasPrices := FindPricesByStids(&gasStationIds, 0, timeframe, false)
125125
return gasPrices
126126
}
127127

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

138-
func findPricesByStids(stids *[]string, resultLimit int, timeframe TimeFrame) []gsmodel.GasPrice {
138+
func findPricesByStids(stids *[]string, resultLimit int, timeframe TimeFrame, onlyLastUpdate bool) []gsmodel.GasPrice {
139139
var myGasPrices []gsmodel.GasPrice
140140
var myTimeFrame time.Time
141141
if timeframe == Day {
@@ -156,7 +156,10 @@ func findPricesByStids(stids *[]string, resultLimit int, timeframe TimeFrame) []
156156
}
157157
myQuery.Find(&values)
158158
//log.Printf("%v", values)
159-
var lastUpdates = returnLastUpdatesGasStation(&values)
159+
var lastUpdates = values
160+
if onlyLastUpdate {
161+
lastUpdates = returnLastUpdatesGasStation(&values)
162+
}
160163
//log.Printf("%v", lastUpdates)
161164
myGasPrices = append(myGasPrices, lastUpdates...)
162165
}

backend/pkd/gasstation/gsrepo.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func UpdatePrice(gasStationPrices *[]GasStationPrices) {
9595
stationPricesKeys = append(stationPricesKeys, value.GasStationID)
9696
}
9797
gasPriceUpdateMap := make(map[string]gsmodel.GasPrice)
98-
stationPricesDb := FindPricesByStids(&stationPricesKeys, 0, Month)
98+
stationPricesDb := FindPricesByStids(&stationPricesKeys, 0, Month, true)
9999
log.Printf("StationPricesKeys: %v StationPricesDb: %v", len(stationPricesKeys), len(stationPricesDb))
100100
for _, value := range stationPricesDb {
101101
if _, found := gasPriceUpdateMap[value.GasStationID]; !found {
@@ -383,8 +383,8 @@ func FindById(id string) gsmodel.GasStation {
383383
return myGasStation
384384
}
385385

386-
func FindPricesByStids(stids *[]string, resultLimit int, timeframe TimeFrame) []gsmodel.GasPrice {
387-
myGasPrice := findPricesByStids(stids, resultLimit, timeframe)
386+
func FindPricesByStids(stids *[]string, resultLimit int, timeframe TimeFrame, onlyLastUpdate bool) []gsmodel.GasPrice {
387+
myGasPrice := findPricesByStids(stids, resultLimit, timeframe, onlyLastUpdate)
388388
return myGasPrice
389389
}
390390

0 commit comments

Comments
 (0)