1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2024-11-20 19:05:57 +01:00

Rename pduid_pdus to pduid_pdu

This commit is contained in:
timokoesters 2020-04-11 09:35:06 +02:00
parent fd829bfa0d
commit ab8c2f1e5e
No known key found for this signature in database
GPG key ID: 356E705610F626D5
2 changed files with 10 additions and 10 deletions

View file

@ -189,7 +189,7 @@ impl Data {
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
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) {
true
} else {
@ -238,7 +238,7 @@ impl Data {
serde_json::from_slice(
&self
.db
.pduid_pdus
.pduid_pdu
.get(pdu_id)
.unwrap()
.expect("eventid_pduid in db is valid"),
@ -340,7 +340,7 @@ impl Data {
let index = utils::u64_from_bytes(
&self
.db
.pduid_pdus
.pduid_pdu
.update_and_fetch(&count_key, utils::increment)
.unwrap()
.unwrap(),
@ -353,7 +353,7 @@ impl Data {
pdu_id.extend_from_slice(&index.to_be_bytes());
self.db
.pduid_pdus
.pduid_pdu
.insert(&pdu_id, &*serde_json::to_string(&pdu).unwrap())
.unwrap();
@ -375,7 +375,7 @@ impl Data {
utils::u64_from_bytes(
&self
.db
.pduid_pdus
.pduid_pdu
.get(&count_key)
.unwrap()
.unwrap_or_else(|| (&0_u64.to_be_bytes()).into()),
@ -394,7 +394,7 @@ impl Data {
let mut current = prefix.clone();
current.extend_from_slice(&since.to_be_bytes());
while let Some((key, value)) = self.db.pduid_pdus.get_gt(&current).unwrap() {
while let Some((key, value)) = self.db.pduid_pdu.get_gt(&current).unwrap() {
if key.starts_with(&prefix) {
current = key.to_vec();
pdus.push(serde_json::from_slice(&value).expect("pdu in db is valid"));

View file

@ -57,7 +57,7 @@ pub struct Database {
pub userid_avatarurl: sled::Tree,
pub deviceid_token: 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 roomid_pduleaves: MultiValue,
pub roomid_userids: MultiValue,
@ -92,7 +92,7 @@ impl Database {
userid_avatarurl: db.open_tree("userid_avatarurl").unwrap(),
deviceid_token: db.open_tree("deviceid_token").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(),
roomid_pduleaves: MultiValue(db.open_tree("roomid_pduleaves").unwrap()),
roomid_userids: MultiValue(db.open_tree("roomid_userids").unwrap()),
@ -174,8 +174,8 @@ impl Database {
String::from_utf8_lossy(&v),
);
}
println!("\n# PDU Id -> PDUs:");
for (k, v) in self.pduid_pdus.iter().map(|r| r.unwrap()) {
println!("\n# PDU Id -> PDU:");
for (k, v) in self.pduid_pdu.iter().map(|r| r.unwrap()) {
println!(
"{:?} -> {:?}",
String::from_utf8_lossy(&k),