Skip to content

Commit

Permalink
Remove group summary cache from user canisters (#5067)
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles authored Dec 21, 2023
1 parent 54a16f4 commit 0cdd6c7
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 422 deletions.
4 changes: 4 additions & 0 deletions backend/canisters/user/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

### Removed

- Remove group summary cache ([#5067](https://github.com/open-chat-labs/open-chat/pull/5067))

## [[2.0.989](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.989-user)] - 2023-12-20

### Added
Expand Down
6 changes: 1 addition & 5 deletions backend/canisters/user/api/can.did
Original file line number Diff line number Diff line change
Expand Up @@ -737,10 +737,6 @@ type MigrateUserPrincipalResponse = variant {
InternalError : text;
};

type InitialStateArgs = record {
disable_cache : opt bool;
};

type InitialStateResponse = variant {
Success : record {
timestamp : TimestampMillis;
Expand Down Expand Up @@ -1043,7 +1039,7 @@ service : {
messages_by_message_index : (MessagesByMessageIndexArgs) -> (MessagesByMessageIndexResponse) query;
deleted_message : (DeletedMessageArgs) -> (DeletedMessageResponse) query;

initial_state : (InitialStateArgs) -> (InitialStateResponse) query;
initial_state : (EmptyArgs) -> (InitialStateResponse) query;
updates : (UpdatesArgs) -> (UpdatesResponse) query;
search_messages : (SearchMessagesArgs) -> (SearchMessagesResponse) query; // Search just the messages of one direct chat
bio : (BioArgs) -> (BioResponse) query;
Expand Down
7 changes: 2 additions & 5 deletions backend/canisters/user/api/src/queries/initial_state.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
use candid::CandidType;
use serde::{Deserialize, Serialize};
use types::{Chat, ChatId, DirectChatSummary, GroupChatSummary, TimestampMillis, UserId};
use types::{Chat, ChatId, DirectChatSummary, Empty, GroupChatSummary, TimestampMillis, UserId};

#[derive(CandidType, Serialize, Deserialize, Debug)]
pub struct Args {
pub disable_cache: Option<bool>,
}
pub type Args = Empty;

#[derive(CandidType, Serialize, Deserialize, Debug)]
pub enum Response {
Expand Down
224 changes: 0 additions & 224 deletions backend/canisters/user/impl/src/group_summaries.rs

This file was deleted.

15 changes: 0 additions & 15 deletions backend/canisters/user/impl/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::model::cached_group_summaries::CachedGroupSummaries;
use crate::model::communities::Communities;
use crate::model::community::Community;
use crate::model::direct_chats::DirectChats;
Expand Down Expand Up @@ -30,7 +29,6 @@ use utils::regular_jobs::RegularJobs;

mod crypto;
mod governance_clients;
mod group_summaries;
mod guards;
mod lifecycle;
mod memory;
Expand Down Expand Up @@ -161,7 +159,6 @@ struct Data {
pub group_index_canister_id: CanisterId,
pub notifications_canister_id: CanisterId,
pub proposals_bot_canister_id: CanisterId,
#[serde(default = "escrow_canister_id")]
pub escrow_canister_id: CanisterId,
pub avatar: Timestamped<Option<Document>>,
pub test_mode: bool,
Expand All @@ -170,7 +167,6 @@ struct Data {
pub username: Timestamped<String>,
pub display_name: Timestamped<Option<String>>,
pub bio: Timestamped<String>,
pub cached_group_summaries: Option<CachedGroupSummaries>,
pub storage_limit: u64,
pub phone_is_verified: bool,
pub user_created: TimestampMillis,
Expand All @@ -183,15 +179,10 @@ struct Data {
pub saved_crypto_accounts: Vec<NamedAccount>,
pub next_event_expiry: Option<TimestampMillis>,
pub token_swaps: TokenSwaps,
#[serde(default)]
pub p2p_trades: P2PTrades,
pub rng_seed: [u8; 32],
}

fn escrow_canister_id() -> CanisterId {
CanisterId::from_text("s4yi7-yiaaa-aaaar-qacpq-cai").unwrap()
}

impl Data {
#[allow(clippy::too_many_arguments)]
pub fn new(
Expand Down Expand Up @@ -226,7 +217,6 @@ impl Data {
username: Timestamped::new(username, now),
display_name: Timestamped::default(),
bio: Timestamped::new("".to_string(), now),
cached_group_summaries: None,
storage_limit: 0,
phone_is_verified: false,
user_created: now,
Expand Down Expand Up @@ -263,11 +253,6 @@ impl Data {
pub fn remove_group(&mut self, chat_id: ChatId, now: TimestampMillis) -> Option<GroupChat> {
self.favourite_chats.remove(&Chat::Group(chat_id), now);
self.hot_group_exclusions.add(chat_id, None, now);

if let Some(cached_groups) = &mut self.cached_group_summaries {
cached_groups.remove_group(&chat_id);
}

self.group_chats.remove(chat_id, now)
}

Expand Down
29 changes: 0 additions & 29 deletions backend/canisters/user/impl/src/model/cached_group_summaries.rs

This file was deleted.

1 change: 0 additions & 1 deletion backend/canisters/user/impl/src/model/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pub mod cached_group_summaries;
pub mod communities;
pub mod community;
pub mod contacts;
Expand Down
Loading

0 comments on commit 0cdd6c7

Please sign in to comment.