File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -117,4 +117,6 @@ pub enum Command {
117117 /// user id / project id / email
118118 query : String ,
119119 } ,
120+
121+ DowngradeProTrials ,
120122}
Original file line number Diff line number Diff line change @@ -167,4 +167,17 @@ impl Client {
167167
168168 Ok ( ( ) )
169169 }
170+
171+ pub async fn get_expired_protrials ( & self ) -> Result < Vec < String > > {
172+ self . inner . get_json ( "/admin/users/protrial-downgrade" ) . await
173+ }
174+
175+ pub async fn downgrade_protrial ( & self , user_id : & str ) -> Result < String > {
176+ self . inner
177+ . put_json (
178+ format ! ( "/admin/users/protrial-downgrade/{user_id}" ) ,
179+ Option :: < ( ) > :: None ,
180+ )
181+ . await
182+ }
170183}
Original file line number Diff line number Diff line change @@ -150,6 +150,20 @@ pub async fn run(args: Args) {
150150 let v = client. get_user_everything ( & query) . await . unwrap ( ) ;
151151 println ! ( "{}" , serde_json:: to_string_pretty( & v) . unwrap( ) ) ;
152152 }
153+ Command :: DowngradeProTrials => {
154+ let users = client. get_expired_protrials ( ) . await . unwrap ( ) ;
155+ eprintln ! (
156+ "Starting downgrade of {} users in 5 seconds..." ,
157+ users. len( )
158+ ) ;
159+ tokio:: time:: sleep ( tokio:: time:: Duration :: from_millis ( 5000 ) ) . await ;
160+ for user_id in users {
161+ println ! ( "{user_id}" ) ;
162+ println ! ( " {:?}" , client. downgrade_protrial( & user_id) . await ) ;
163+ // prevent api rate limiting
164+ tokio:: time:: sleep ( tokio:: time:: Duration :: from_millis ( 1000 ) ) . await ;
165+ }
166+ }
153167 } ;
154168}
155169
You can’t perform that action at this time.
0 commit comments