Skip to content

Commit e6061ca

Browse files
committed
Renamed InDbMenuCache to GCloudMenuCache
1 parent 1638957 commit e6061ca

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/cache/menu_cache.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,22 @@ use firestore::FirestoreDb;
99
use futures::{stream::FuturesUnordered, StreamExt};
1010
use log::info;
1111
use tokio::io::AsyncReadExt;
12-
1312
const CACHES_COLLECTION: &str = "caches";
14-
1513
#[derive(Debug)]
1614
pub struct MenuCache<'a> {
1715
cached_at: DateTime<Utc>,
1816
locations: Locations<'a>,
1917
}
20-
2118
#[derive(serde::Serialize, serde::Deserialize, Default)]
22-
struct InDbMenuCache {
19+
struct GCloudMenuCache {
2320
cached_at: DateTime<Utc>,
2421
data: Vec<u8>,
2522
}
2623

2724
pub static REFRESH_INTERVAL: chrono::Duration = chrono::Duration::minutes(15);
2825

2926
impl<'a> MenuCache<'a> {
30-
async fn from_async(cache: InDbMenuCache) -> Self {
27+
async fn from_async(cache: GCloudMenuCache) -> Self {
3128
if cache.data.is_empty() {
3229
return MenuCache {
3330
cached_at: cache.cached_at,
@@ -85,7 +82,7 @@ impl<'a> MenuCache<'a> {
8582

8683
async fn fetch_from_db() -> Result<Self, crate::error::Error> {
8784
let db = FirestoreDb::new("ucsc-menu").await?;
88-
let cache: InDbMenuCache = db
85+
let cache: GCloudMenuCache = db
8986
.fluent()
9087
.select()
9188
.by_id_in(CACHES_COLLECTION)
@@ -96,7 +93,7 @@ impl<'a> MenuCache<'a> {
9693
Ok(MenuCache::from_async(cache).await)
9794
}
9895

99-
async fn to_db_representation(&self) -> InDbMenuCache {
96+
async fn to_db_representation(&self) -> GCloudMenuCache {
10097
let json = serde_json::to_string(self.locations()).unwrap();
10198
let mut compressed = Vec::with_capacity(json.len() / 4);
10299
let mut compress =
@@ -105,14 +102,14 @@ impl<'a> MenuCache<'a> {
105102
.read_buf(&mut compressed)
106103
.await
107104
.expect("This should succeed");
108-
InDbMenuCache {
105+
GCloudMenuCache {
109106
cached_at: self.cached_at,
110107
data: compressed,
111108
}
112109
}
113110

114111
async fn save_to_db(&self) -> Result<(), firestore::errors::FirestoreError> {
115-
let cache: InDbMenuCache = self.to_db_representation().await;
112+
let cache: GCloudMenuCache = self.to_db_representation().await;
116113
let db = FirestoreDb::new("ucsc-menu").await?;
117114
db.fluent()
118115
.update()

src/parse/location_page/locations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ mod tests {
180180
.parse()
181181
.expect("url should be valid");
182182
let mut location = Location::new(LocationMeta::from_url(url).unwrap());
183-
let v = vec![html];
183+
let v = [html];
184184
location.add_meals(v.iter()).unwrap();
185185
assert!(location.hydrated());
186186
let root = RootNode::new(

0 commit comments

Comments
 (0)