@@ -121,7 +121,7 @@ func findGasPricesByTimeframe(postCodeGasStationsMap *map[string][]gsmodel.GasSt
121
121
}
122
122
}
123
123
//log.Printf("gasStationIds: %v", len(gasStationIds))
124
- gasPrices := FindPricesByStidsDistinct (& gasStationIds , 0 , timeframe )
124
+ gasPrices := FindPricesByStids (& gasStationIds , 0 , timeframe )
125
125
return gasPrices
126
126
}
127
127
@@ -135,9 +135,8 @@ func createPostCodeGasStationsMap() map[string][]gsmodel.GasStation {
135
135
return postCodeGasStationsMap
136
136
}
137
137
138
- func findPricesByStids (stids * []string , resultLimit int , distinct bool , timeframe TimeFrame ) []gsmodel.GasPrice {
138
+ func findPricesByStids (stids * []string , resultLimit int , timeframe TimeFrame ) []gsmodel.GasPrice {
139
139
var myGasPrices []gsmodel.GasPrice
140
- gasStationidGasPriceMap := make (map [string ]gsmodel.GasPrice )
141
140
var myTimeFrame time.Time
142
141
if timeframe == Day {
143
142
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
157
156
}
158
157
myQuery .Find (& values )
159
158
//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 ... )
172
160
}
173
161
return nil
174
162
})
0 commit comments