Rename pduid_pdus to pduid_pdu
This commit is contained in:
parent
fd829bfa0d
commit
ab8c2f1e5e
12
src/data.rs
12
src/data.rs
|
@ -189,7 +189,7 @@ impl Data {
|
||||||
prefix.extend_from_slice(room_id.to_string().as_bytes());
|
prefix.extend_from_slice(room_id.to_string().as_bytes());
|
||||||
prefix.push(b'#'); // Add delimiter so we don't find rooms starting with the same id
|
prefix.push(b'#'); // Add delimiter so we don't find rooms starting with the same id
|
||||||
|
|
||||||
if let Some((key, _)) = self.db.pduid_pdus.get_gt(&prefix).unwrap() {
|
if let Some((key, _)) = self.db.pduid_pdu.get_gt(&prefix).unwrap() {
|
||||||
if key.starts_with(&prefix) {
|
if key.starts_with(&prefix) {
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
|
@ -238,7 +238,7 @@ impl Data {
|
||||||
serde_json::from_slice(
|
serde_json::from_slice(
|
||||||
&self
|
&self
|
||||||
.db
|
.db
|
||||||
.pduid_pdus
|
.pduid_pdu
|
||||||
.get(pdu_id)
|
.get(pdu_id)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.expect("eventid_pduid in db is valid"),
|
.expect("eventid_pduid in db is valid"),
|
||||||
|
@ -340,7 +340,7 @@ impl Data {
|
||||||
let index = utils::u64_from_bytes(
|
let index = utils::u64_from_bytes(
|
||||||
&self
|
&self
|
||||||
.db
|
.db
|
||||||
.pduid_pdus
|
.pduid_pdu
|
||||||
.update_and_fetch(&count_key, utils::increment)
|
.update_and_fetch(&count_key, utils::increment)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
|
@ -353,7 +353,7 @@ impl Data {
|
||||||
pdu_id.extend_from_slice(&index.to_be_bytes());
|
pdu_id.extend_from_slice(&index.to_be_bytes());
|
||||||
|
|
||||||
self.db
|
self.db
|
||||||
.pduid_pdus
|
.pduid_pdu
|
||||||
.insert(&pdu_id, &*serde_json::to_string(&pdu).unwrap())
|
.insert(&pdu_id, &*serde_json::to_string(&pdu).unwrap())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@ -375,7 +375,7 @@ impl Data {
|
||||||
utils::u64_from_bytes(
|
utils::u64_from_bytes(
|
||||||
&self
|
&self
|
||||||
.db
|
.db
|
||||||
.pduid_pdus
|
.pduid_pdu
|
||||||
.get(&count_key)
|
.get(&count_key)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap_or_else(|| (&0_u64.to_be_bytes()).into()),
|
.unwrap_or_else(|| (&0_u64.to_be_bytes()).into()),
|
||||||
|
@ -394,7 +394,7 @@ impl Data {
|
||||||
let mut current = prefix.clone();
|
let mut current = prefix.clone();
|
||||||
current.extend_from_slice(&since.to_be_bytes());
|
current.extend_from_slice(&since.to_be_bytes());
|
||||||
|
|
||||||
while let Some((key, value)) = self.db.pduid_pdus.get_gt(¤t).unwrap() {
|
while let Some((key, value)) = self.db.pduid_pdu.get_gt(¤t).unwrap() {
|
||||||
if key.starts_with(&prefix) {
|
if key.starts_with(&prefix) {
|
||||||
current = key.to_vec();
|
current = key.to_vec();
|
||||||
pdus.push(serde_json::from_slice(&value).expect("pdu in db is valid"));
|
pdus.push(serde_json::from_slice(&value).expect("pdu in db is valid"));
|
||||||
|
|
|
@ -57,7 +57,7 @@ pub struct Database {
|
||||||
pub userid_avatarurl: sled::Tree,
|
pub userid_avatarurl: sled::Tree,
|
||||||
pub deviceid_token: sled::Tree,
|
pub deviceid_token: sled::Tree,
|
||||||
pub token_userid: sled::Tree,
|
pub token_userid: sled::Tree,
|
||||||
pub pduid_pdus: sled::Tree,
|
pub pduid_pdu: sled::Tree, // PduId = RoomId + Since
|
||||||
pub eventid_pduid: sled::Tree,
|
pub eventid_pduid: sled::Tree,
|
||||||
pub roomid_pduleaves: MultiValue,
|
pub roomid_pduleaves: MultiValue,
|
||||||
pub roomid_userids: MultiValue,
|
pub roomid_userids: MultiValue,
|
||||||
|
@ -92,7 +92,7 @@ impl Database {
|
||||||
userid_avatarurl: db.open_tree("userid_avatarurl").unwrap(),
|
userid_avatarurl: db.open_tree("userid_avatarurl").unwrap(),
|
||||||
deviceid_token: db.open_tree("deviceid_token").unwrap(),
|
deviceid_token: db.open_tree("deviceid_token").unwrap(),
|
||||||
token_userid: db.open_tree("token_userid").unwrap(),
|
token_userid: db.open_tree("token_userid").unwrap(),
|
||||||
pduid_pdus: db.open_tree("pduid_pdus").unwrap(),
|
pduid_pdu: db.open_tree("pduid_pdu").unwrap(),
|
||||||
eventid_pduid: db.open_tree("eventid_pduid").unwrap(),
|
eventid_pduid: db.open_tree("eventid_pduid").unwrap(),
|
||||||
roomid_pduleaves: MultiValue(db.open_tree("roomid_pduleaves").unwrap()),
|
roomid_pduleaves: MultiValue(db.open_tree("roomid_pduleaves").unwrap()),
|
||||||
roomid_userids: MultiValue(db.open_tree("roomid_userids").unwrap()),
|
roomid_userids: MultiValue(db.open_tree("roomid_userids").unwrap()),
|
||||||
|
@ -174,8 +174,8 @@ impl Database {
|
||||||
String::from_utf8_lossy(&v),
|
String::from_utf8_lossy(&v),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
println!("\n# PDU Id -> PDUs:");
|
println!("\n# PDU Id -> PDU:");
|
||||||
for (k, v) in self.pduid_pdus.iter().map(|r| r.unwrap()) {
|
for (k, v) in self.pduid_pdu.iter().map(|r| r.unwrap()) {
|
||||||
println!(
|
println!(
|
||||||
"{:?} -> {:?}",
|
"{:?} -> {:?}",
|
||||||
String::from_utf8_lossy(&k),
|
String::from_utf8_lossy(&k),
|
||||||
|
|
Loading…
Reference in New Issue