diff options
Diffstat (limited to 'src/boot')
| -rw-r--r-- | src/boot/app.rs | 30 | ||||
| -rw-r--r-- | src/boot/handlers/boot/test.rs | 22 | ||||
| -rw-r--r-- | src/boot/mod.rs | 5 |
3 files changed, 11 insertions, 46 deletions
diff --git a/src/boot/app.rs b/src/boot/app.rs index 690bcf4..89eec12 100644 --- a/src/boot/app.rs +++ b/src/boot/app.rs @@ -23,42 +23,27 @@ impl<'a> Boot<'a> { let mut tx = self.db.begin().await?; let resume_point = tx.sequence().current().await?; - let user_histories = tx.users().all(resume_point).await?; - let channel_histories = tx.channels().all(resume_point).await?; - let message_histories = tx.messages().all(resume_point).await?; + let users = tx.users().all(resume_point).await?; + let channels = tx.channels().all(resume_point).await?; + let messages = tx.messages().all(resume_point).await?; tx.commit().await?; - let users = user_histories - .iter() - .filter_map(|user| user.as_of(resume_point)) - .collect(); - - let channels = channel_histories - .iter() - .filter_map(|channel| channel.as_of(resume_point)) - .collect(); - - let messages = message_histories - .iter() - .filter_map(|message| message.as_of(resume_point)) - .collect(); - - let user_events = user_histories + let user_events = users .iter() .map(user::History::events) .kmerge_by(Sequence::merge) .filter(Sequence::up_to(resume_point)) .map(Event::from); - let channel_events = channel_histories + let channel_events = channels .iter() .map(channel::History::events) .kmerge_by(Sequence::merge) .filter(Sequence::up_to(resume_point)) .map(Event::from); - let message_events = message_histories + let message_events = messages .iter() .map(message::History::events) .kmerge_by(Sequence::merge) @@ -72,9 +57,6 @@ impl<'a> Boot<'a> { Ok(Snapshot { resume_point, - users, - channels, - messages, events, }) } diff --git a/src/boot/handlers/boot/test.rs b/src/boot/handlers/boot/test.rs index d68618e..1e590a7 100644 --- a/src/boot/handlers/boot/test.rs +++ b/src/boot/handlers/boot/test.rs @@ -25,8 +25,6 @@ async fn includes_users() { .await .expect("boot always succeeds"); - assert!(response.snapshot.users.contains(&spectator)); - let created = response .snapshot .events @@ -48,8 +46,6 @@ async fn includes_channels() { .await .expect("boot always succeeds"); - assert!(response.snapshot.channels.contains(&channel)); - let created = response .snapshot .events @@ -73,8 +69,6 @@ async fn includes_messages() { .await .expect("boot always succeeds"); - assert!(response.snapshot.messages.contains(&message)); - let sent = response .snapshot .events @@ -87,7 +81,7 @@ async fn includes_messages() { } #[tokio::test] -async fn excludes_expired_messages() { +async fn includes_expired_messages() { let app = fixtures::scratch_app().await; let sender = fixtures::user::create(&app, &fixtures::ancient()).await; let channel = fixtures::channel::create(&app, &fixtures::ancient()).await; @@ -104,8 +98,6 @@ async fn excludes_expired_messages() { .await .expect("boot always succeeds"); - assert!(!response.snapshot.messages.contains(&expired_message)); - let sent = response .snapshot .events @@ -131,7 +123,7 @@ async fn excludes_expired_messages() { } #[tokio::test] -async fn excludes_deleted_messages() { +async fn includes_deleted_messages() { let app = fixtures::scratch_app().await; let sender = fixtures::user::create(&app, &fixtures::now()).await; let channel = fixtures::channel::create(&app, &fixtures::now()).await; @@ -147,8 +139,6 @@ async fn excludes_deleted_messages() { .await .expect("boot always succeeds"); - assert!(!response.snapshot.messages.contains(&deleted_message)); - let sent = response .snapshot .events @@ -174,7 +164,7 @@ async fn excludes_deleted_messages() { } #[tokio::test] -async fn excludes_expired_channels() { +async fn includes_expired_channels() { let app = fixtures::scratch_app().await; let expired_channel = fixtures::channel::create(&app, &fixtures::ancient()).await; @@ -188,8 +178,6 @@ async fn excludes_expired_channels() { .await .expect("boot always succeeds"); - assert!(!response.snapshot.channels.contains(&expired_channel)); - let created = response .snapshot .events @@ -215,7 +203,7 @@ async fn excludes_expired_channels() { } #[tokio::test] -async fn excludes_deleted_channels() { +async fn includes_deleted_channels() { let app = fixtures::scratch_app().await; let deleted_channel = fixtures::channel::create(&app, &fixtures::now()).await; @@ -229,8 +217,6 @@ async fn excludes_deleted_channels() { .await .expect("boot always succeeds"); - assert!(!response.snapshot.channels.contains(&deleted_channel)); - let created = response .snapshot .events diff --git a/src/boot/mod.rs b/src/boot/mod.rs index 148e87d..e0d35d9 100644 --- a/src/boot/mod.rs +++ b/src/boot/mod.rs @@ -1,4 +1,4 @@ -use crate::{channel::Channel, event::Event, event::Sequence, message::Message, user::User}; +use crate::{event::Event, event::Sequence}; pub mod app; pub mod handlers; @@ -6,8 +6,5 @@ pub mod handlers; #[derive(serde::Serialize)] pub struct Snapshot { pub resume_point: Sequence, - pub users: Vec<User>, - pub channels: Vec<Channel>, - pub messages: Vec<Message>, pub events: Vec<Event>, } |
