-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ai-help): delete ai history after six months #437
Conversation
src/db/v2/mod.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder what v2
under db
refer to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not know, I put it there for consistency w.r.t. the bcd updates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After talking to @fiji-flo, I will move things around a bit.
This pull request has merge conflicts that must be resolved before it can be merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just some thoughts.
let mut retry = 0; | ||
const MAX_RETRIES: u32 = 40; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious why you use u32
, since u8
would be sufficient for both, and the difference is probably negligible here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, u8 would suffice here. It is test code though, so I we can be a bit more relaxed about this.
loop { | ||
records = ai_help_history::table | ||
.filter(ai_help_history::user_id.eq(1)) | ||
.select(ai_help_history::updated_at) | ||
.get_results(&mut conn)?; | ||
if records.len() == 1 { | ||
break; | ||
} | ||
|
||
actix_rt::time::sleep(Duration::from_millis(5)).await; | ||
retry += 1; | ||
if retry > MAX_RETRIES { | ||
break; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this could be made more readable by using the retry
crate, and we could reuse it to stabilize those flaky tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, probably. Lets look into retry crate next time we have flakyness issues.
if let Err(e) = do_delete_old_ai_history(pool).await { | ||
error!("{}", e); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering out loud if this would be "more" idiomatic:
if let Err(e) = do_delete_old_ai_history(pool).await { | |
error!("{}", e); | |
} | |
do_delete_old_ai_history(pool) | |
.await | |
.map_err(|e| error!("{}", e)) | |
.ok(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it looks more rustful.
Adds a new admin endpoint that deletes all ai help history entries form the database that are more that 6 months old.
(MP-712)