diff --git a/profiles/src/store/submission.rs b/profiles/src/store/submission.rs index aaaafa8..ab5071a 100644 --- a/profiles/src/store/submission.rs +++ b/profiles/src/store/submission.rs @@ -264,9 +264,9 @@ impl Store { }) .into_iter() .flat_map(move |published| { - let range_start = published_submission_range_start(published); - let range_start = range_start.as_bytes().to_vec(); - this.published_date_range(range_start..) + let range_entry = published_submission_range_start(published); + let range_entry = range_entry.as_bytes().to_vec(); + this.published_date_range(range_entry..) }) } @@ -281,9 +281,9 @@ impl Store { }) .into_iter() .flat_map(move |published| { - let range_end = published_submission_range_start(published); - let range_end = range_end.as_bytes().to_vec(); - this.published_date_range(..range_end) + let range_entry = published_submission_range_start(published); + let range_entry = range_entry.as_bytes().to_vec(); + this.published_date_range(..range_entry) }) .rev() } @@ -320,9 +320,9 @@ impl Store { self.extract(id, |s| Some((s.profile_id, s.drafted_at))) .into_iter() .flat_map(move |(profile_id, drafted)| { - let range_start = profile_id_drafted_submission_range_start(profile_id, drafted); - let range_start = range_start.as_bytes().to_vec(); - this.drafted_date_range_for_profile(range_start..) + let range_end = profile_id_drafted_submission_range_end(profile_id); + let range_entry = profile_id_drafted_submission_range_entry(profile_id, drafted); + this.drafted_date_range_for_profile(range_entry..range_end) }) } @@ -335,9 +335,9 @@ impl Store { self.extract(id, |s| Some((s.profile_id, s.drafted_at))) .into_iter() .flat_map(move |(profile_id, drafted)| { - let range_end = profile_id_drafted_submission_range_start(profile_id, drafted); - let range_end = range_end.as_bytes().to_vec(); - this.drafted_date_range_for_profile(..range_end) + let range_start = profile_id_drafted_submission_range_beginning(profile_id); + let range_entry = profile_id_drafted_submission_range_entry(profile_id, drafted); + this.drafted_date_range_for_profile(range_start..range_entry) }) .rev() } @@ -374,10 +374,9 @@ impl Store { self.extract(id, |s| s.published.map(|p| (s.profile_id, p))) .into_iter() .flat_map(move |(profile_id, published)| { - let range_start = - profile_id_published_submission_range_start(profile_id, published); - let range_start = range_start.as_bytes().to_vec(); - this.published_date_range_for_profile(range_start..) + let range_end = profile_id_publshed_submission_range_end(profile_id); + let range_entry = profile_id_publshed_submission_range_entry(profile_id, published); + this.published_date_range_for_profile(range_entry..range_end) }) } @@ -390,9 +389,9 @@ impl Store { self.extract(id, |s| s.published.map(|p| (s.profile_id, p))) .into_iter() .flat_map(move |(profile_id, published)| { - let range_end = profile_id_published_submission_range_start(profile_id, published); - let range_end = range_end.as_bytes().to_vec(); - this.published_date_range_for_profile(..range_end) + let range_start = profile_id_publshed_submission_range_beginning(profile_id); + let range_entry = profile_id_publshed_submission_range_entry(profile_id, published); + this.published_date_range_for_profile(range_start..range_entry) }) .rev() } @@ -499,7 +498,11 @@ fn profile_id_drafted_submission_key( ) } -fn profile_id_drafted_submission_range_start( +fn profile_id_drafted_submission_range_beginning(profile_id: Uuid) -> String { + format!("/profile/{}/drafted/", profile_id) +} + +fn profile_id_drafted_submission_range_entry( profile_id: Uuid, drafted_at: DateTime, ) -> String { @@ -510,6 +513,10 @@ fn profile_id_drafted_submission_range_start( ) } +fn profile_id_drafted_submission_range_end(profile_id: Uuid) -> String { + format!("/profile/{}/draftee/", profile_id) +} + fn published_profile_submission_key( profile_id: Uuid, published: DateTime, @@ -535,7 +542,11 @@ fn published_submission_range_start(published: DateTime) -> String { format!("/published/{}", published.to_rfc3339()) } -fn profile_id_published_submission_range_start( +fn profile_id_publshed_submission_range_beginning(profile_id: Uuid) -> String { + format!("/profile/{}/published/", profile_id) +} + +fn profile_id_publshed_submission_range_entry( profile_id: Uuid, published: DateTime, ) -> String { @@ -546,6 +557,10 @@ fn profile_id_published_submission_range_start( ) } +fn profile_id_publshed_submission_range_end(profile_id: Uuid) -> String { + format!("/profile/{}/publishee/", profile_id) +} + fn profile_id_submission_count_key(profile_id: Uuid) -> String { format!("/profile/{}/count", profile_id) } diff --git a/profiles/src/store/view/notif.rs b/profiles/src/store/view/notif.rs index bd04d78..bda09b1 100644 --- a/profiles/src/store/view/notif.rs +++ b/profiles/src/store/view/notif.rs @@ -19,6 +19,10 @@ struct NotificationKeys { } impl NotificationKeys { + fn notification_start(&self, profile_id: Uuid) -> String { + format!("/profiles/{}/created/", profile_id) + } + fn notification_key( &self, profile_id: Uuid, @@ -34,6 +38,10 @@ impl NotificationKeys { ) } + fn notification_end(&self, profile_id: Uuid) -> String { + format!("/profile/{}/createe/", profile_id) + } + fn date_key(&self, profile_id: Uuid, notification_id: Uuid) -> String { format!( "/profile/{}/{}/{}", @@ -321,9 +329,8 @@ impl NotificationStore { let keys = keys.clone(); self.notifications .range( - ..keys - .notification_key(profile_id, date, notification_id) - .as_bytes(), + keys.notification_start(profile_id) + ..keys.notification_key(profile_id, date, notification_id), ) .values() .filter_map(|res| res.ok()) @@ -349,7 +356,7 @@ impl NotificationStore { self.notifications .range( keys.notification_key(profile_id, date, notification_id) - .as_bytes().., + ..keys.notification_end(profile_id), ) .values() .filter_map(|res| res.ok())