Skip to content

Commit

Permalink
feat: fixing activity ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
112batuhan committed Dec 8, 2024
1 parent a17db32 commit cced7aa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/handlers/activity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ impl ActivityTracker {

pub fn add_new_activity_to_queue(&self, new_activity: Activity) -> Result<(), AppError> {
let mut locked_queue = self.lock_activity_queue()?;
locked_queue.push_back(new_activity);
locked_queue.push_front(new_activity);
if locked_queue.len() > self.queue_size.into() {
locked_queue.pop_front();
locked_queue.pop_back();
}
Ok(())
}
Expand Down Expand Up @@ -296,7 +296,7 @@ impl ActivityTracker {
// unoptimized lock usage doesn't matter here.
// This is only going to run at the start of the program once
if self.spam_prevention(&activity)? {
self.lock_activity_queue()?.push_back(activity);
self.lock_activity_queue()?.push_front(activity);
}
if self.lock_activity_queue()?.len() >= self.queue_size.into() {
break 'outer;
Expand Down

0 comments on commit cced7aa

Please sign in to comment.