Skip to content

Commit

Permalink
Remove DiamondMembershipExpiryDate that is no longer needed
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles committed Jan 23, 2024
1 parent 7048267 commit b0c8c96
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 26 deletions.
1 change: 0 additions & 1 deletion backend/canisters/local_user_index/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ pub enum Event {
DiamondMembershipPaymentReceived(DiamondMembershipPaymentReceived),
OpenChatBotMessage(Box<OpenChatBotMessage>),
ReferralCodeAdded(ReferralCodeAdded),
DiamondMembershipExpiryDate(UserId, TimestampMillis), // Temp event type to populate expiry dates
}

#[derive(Serialize, Deserialize, Clone, Debug)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,5 @@ fn handle_event(event: Event, state: &mut RuntimeState) {
.referral_codes
.add(ev.referral_type, ev.code, ev.expiry, state.env.now());
}
Event::DiamondMembershipExpiryDate(user_id, expires_at) => {
state
.data
.global_users
.set_diamond_membership_expiry_date(user_id, expires_at);
}
}
}
20 changes: 1 addition & 19 deletions backend/canisters/user_index/impl/src/lifecycle/post_upgrade.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use crate::lifecycle::{init_env, init_state};
use crate::memory::get_upgrades_memory;
use crate::{mutate_state, Data};
use crate::Data;
use canister_logger::LogEntry;
use canister_tracing_macros::trace;
use ic_cdk_macros::post_upgrade;
use local_user_index_canister::Event;
use stable_memory::get_reader;
use tracing::info;
use user_index_canister::post_upgrade::Args;
Expand All @@ -24,22 +23,5 @@ fn post_upgrade(args: Args) {
init_cycles_dispenser_client(data.cycles_dispenser_canister_id, data.test_mode);
init_state(env, data, args.wasm_version);

mutate_state(|state| {
let now = state.env.now();
for user in state.data.users.iter() {
if let Some(expires_at) = user.diamond_membership_details.expires_at() {
if expires_at > now {
for local_user_index_canister_id in state.data.local_index_map.canisters() {
state.data.user_index_event_sync_queue.push(
*local_user_index_canister_id,
Event::DiamondMembershipExpiryDate(user.user_id, expires_at),
);
}
}
}
}
crate::jobs::sync_events_to_local_user_index_canisters::start_job_if_required(state);
});

info!(version = %args.wasm_version, "Post-upgrade complete");
}

0 comments on commit b0c8c96

Please sign in to comment.