Skip to content

Commit

Permalink
Make some metnorwayforecastprovider queries shorter
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtakac committed Nov 6, 2022
1 parent 9f9a9dd commit 516826f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ class MetNorwayForecastProvider(
response?.let {
withContext(ioDispatcher) {
cachedResponseQueries.insert(
latitude = latitude,
longitude = longitude,
response = it
CachedResponse(
latitude = latitude,
longitude = longitude,
response = it
)
)
}
}
Expand All @@ -94,10 +96,12 @@ class MetNorwayForecastProvider(
) {
withContext(ioDispatcher) {
metaQueries.insert(
latitude = latitude,
longitude = longitude,
expires = headers[HttpHeaders.Expires]?.let(zonedDateTimeSqlAdapter::decode),
lastModified = headers[HttpHeaders.LastModified]?.let(zonedDateTimeSqlAdapter::decode)
Meta(
latitude = latitude,
longitude = longitude,
expires = headers[HttpHeaders.Expires]?.let(zonedDateTimeSqlAdapter::decode),
lastModified = headers[HttpHeaders.LastModified]?.let(zonedDateTimeSqlAdapter::decode)
)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ SELECT * FROM CachedResponse
WHERE abs(latitude - :latitude) < 0.00001 AND abs(longitude - :longitude) < 0.00001;

insert:
INSERT OR REPLACE INTO CachedResponse (latitude, longitude, response)
VALUES (?, ?, ?);
INSERT OR REPLACE INTO CachedResponse VALUES ?;
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ SELECT * FROM Meta
WHERE abs(latitude - :latitude) < 0.00001 AND abs(longitude - :longitude) < 0.00001;

insert:
REPLACE INTO Meta (latitude, longitude, expires, lastModified)
VALUES (?, ?, ?, ?);
REPLACE INTO Meta VALUES ?;

0 comments on commit 516826f

Please sign in to comment.