Constellation, Spacedust, Slingshot, UFOs: atproto crates and services for microcosm
75
fork

Configure Feed

Select the types of activity you want to include in your feed.

switch to hashset filter and add another test case

phil 45274245 34266979

+32 -8
+1 -1
constellation/src/storage/mem_store.rs
··· 285 285 path: &str, 286 286 limit: u64, 287 287 until: Option<u64>, 288 - dids: &[Did], 288 + dids: &HashSet<Did>, 289 289 ) -> Result<PagedAppendingCollection<RecordId>> { 290 290 let data = self.0.lock().unwrap(); 291 291 let Some(paths) = data.targets.get(&Target::new(target)) else {
+30 -6
constellation/src/storage/mod.rs
··· 1 1 use crate::{ActionableEvent, CountsByCount, Did, RecordId}; 2 2 use anyhow::Result; 3 3 use serde::{Deserialize, Serialize}; 4 - use std::collections::HashMap; 4 + use std::collections::{HashMap, HashSet}; 5 5 6 6 pub mod mem_store; 7 7 pub use mem_store::MemStorage; ··· 76 76 path: &str, 77 77 limit: u64, 78 78 until: Option<u64>, 79 - dids: &[Did], 79 + dids: &HashSet<Did>, 80 80 ) -> Result<PagedAppendingCollection<RecordId>>; 81 81 82 82 fn get_all_record_counts(&self, _target: &str) ··· 771 771 }); 772 772 773 773 test_each_storage!(get_filtered_links, |storage| { 774 - let links = storage.get_links_from_dids("a.com", "app.t.c", ".abc.uri", 2, None, &[Did("did:plc:linker".to_string())])?; 774 + let links = storage.get_links_from_dids("a.com", "app.t.c", ".abc.uri", 2, None, &HashSet::from([Did("did:plc:linker".to_string())]))?; 775 775 assert_eq!( 776 776 links, 777 777 PagedAppendingCollection { ··· 796 796 0, 797 797 )?; 798 798 799 - let links = storage.get_links_from_dids("a.com", "app.t.c", ".abc.uri", 2, None, &[Did("did:plc:linker".to_string())])?; 799 + let links = storage.get_links_from_dids("a.com", "app.t.c", ".abc.uri", 2, None, &HashSet::from([Did("did:plc:linker".to_string())]))?; 800 800 assert_eq!( 801 801 links, 802 802 PagedAppendingCollection { ··· 812 812 } 813 813 ); 814 814 815 - let links = storage.get_links_from_dids("a.com", "app.t.c", ".abc.uri", 2, None, &[Did("did:plc:someone-else".to_string())])?; 815 + let links = storage.get_links_from_dids("a.com", "app.t.c", ".abc.uri", 2, None, &HashSet::from([Did("did:plc:someone-else".to_string())]))?; 816 816 assert_eq!( 817 817 links, 818 818 PagedAppendingCollection { ··· 851 851 0, 852 852 )?; 853 853 854 - let links = storage.get_links_from_dids("a.com", "app.t.c", ".abc.uri", 2, None, &[Did("did:plc:linker".to_string())])?; 854 + let links = storage.get_links_from_dids("a.com", "app.t.c", ".abc.uri", 2, None, &HashSet::from([Did("did:plc:linker".to_string())]))?; 855 855 assert_eq!( 856 856 links, 857 857 PagedAppendingCollection { ··· 869 869 }, 870 870 ], 871 871 next: None, 872 + } 873 + ); 874 + 875 + let links = storage.get_links_from_dids("a.com", "app.t.c", ".abc.uri", 2, None, &HashSet::from([ 876 + Did("did:plc:linker".to_string()), 877 + Did("did:plc:someone-else".to_string()), 878 + ]))?; 879 + assert_eq!( 880 + links, 881 + PagedAppendingCollection { 882 + version: (3, 0), 883 + items: vec![ 884 + RecordId { 885 + did: "did:plc:someone-else".into(), 886 + collection: "app.t.c".into(), 887 + rkey: "asdf".into(), 888 + }, 889 + RecordId { 890 + did: "did:plc:linker".into(), 891 + collection: "app.t.c".into(), 892 + rkey: "asdf-2".into(), 893 + }, 894 + ], 895 + next: Some(1), 872 896 } 873 897 ); 874 898 });
+1 -1
constellation/src/storage/rocks_store.rs
··· 984 984 path: &str, 985 985 limit: u64, 986 986 until: Option<u64>, 987 - dids: &[Did], 987 + dids: &HashSet<Did>, 988 988 ) -> Result<PagedAppendingCollection<RecordId>> { 989 989 let target_key = TargetKey( 990 990 Target(target.to_string()),