Skip to content

Commit 086a3ef

Browse files
authored
feat(admin): log retention policies (#2053)
1 parent cc20391 commit 086a3ef

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

admin/src/args.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,5 @@ pub enum Command {
119119
},
120120

121121
DowngradeProTrials,
122+
FixRetentionPolicies,
122123
}

admin/src/client.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ impl Client {
166166
pub async fn get_expired_protrials(&self) -> Result<Vec<String>> {
167167
self.inner.get_json("/admin/users/protrial-downgrade").await
168168
}
169-
170169
pub async fn downgrade_protrial(&self, user_id: &str) -> Result<String> {
171170
self.inner
172171
.put_json(
@@ -175,4 +174,16 @@ impl Client {
175174
)
176175
.await
177176
}
177+
178+
pub async fn get_projects_for_retention_policy(&self) -> Result<Vec<String>> {
179+
self.inner.get_json("/admin/log-retention").await
180+
}
181+
pub async fn fix_retention_policy(&self, project_id: &str) -> Result<String> {
182+
self.inner
183+
.put_json(
184+
format!("/admin/log-retention/{project_id}"),
185+
Option::<()>::None,
186+
)
187+
.await
188+
}
178189
}

admin/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,16 @@ pub async fn run(args: Args) {
164164
tokio::time::sleep(tokio::time::Duration::from_millis(1000)).await;
165165
}
166166
}
167+
Command::FixRetentionPolicies => {
168+
let projects = client.get_projects_for_retention_policy().await.unwrap();
169+
eprintln!("Starting fix of {} log retention policies", projects.len());
170+
for pid in projects {
171+
println!("{pid}");
172+
println!(" {:?}", client.fix_retention_policy(&pid).await);
173+
// prevent api rate limiting
174+
tokio::time::sleep(tokio::time::Duration::from_millis(1000)).await;
175+
}
176+
}
167177
};
168178
}
169179

0 commit comments

Comments
 (0)