@@ -36,14 +36,14 @@ impl Write for LogWriter {
3636
3737#[ derive( Deserialize ) ]
3838struct Config {
39- new_orders_webhook : String ,
40- order_updates_webhook : String ,
39+ new_orders_webhook : Option < String > ,
40+ order_updates_webhook : Option < String > ,
4141}
4242
4343struct UsrState {
4444 db : DatabaseConnection ,
45- new_orders_webhook : DiscordWebhook ,
46- order_updates_webhook : DiscordWebhook ,
45+ new_orders_webhook : Option < DiscordWebhook > ,
46+ order_updates_webhook : Option < DiscordWebhook > ,
4747}
4848
4949#[ tokio:: main]
@@ -84,10 +84,29 @@ async fn main() -> anyhow::Result<()> {
8484
8585 if Path :: new ( ".reset-db" ) . exists ( ) {
8686 info ! ( "Resetting DB" ) ;
87+ let directive = std:: fs:: read_to_string ( ".reset-db" ) ?;
88+
89+ match directive. as_str ( ) {
90+ "scheduler" => {
91+ scheduler:: reset_tables ( & db) . await ?;
92+ info ! ( "Reset scheduler tables" ) ;
93+ }
94+ "manifest" => {
95+ manifest:: reset_tables ( & db) . await ?;
96+ info ! ( "Reset manifest tables" ) ;
97+ }
98+ "all" => {
99+ scheduler:: reset_tables ( & db) . await ?;
100+ manifest:: reset_tables ( & db) . await ?;
101+ info ! ( "Reset all tables" ) ;
102+ }
103+ _ => {
104+ error ! ( "Invalid directive in .reset-db" ) ;
105+ return Ok ( ( ) ) ;
106+ }
107+ }
108+
87109 std:: fs:: remove_file ( ".reset-db" ) ?;
88- scheduler:: reset_tables ( & db) . await ?;
89- manifest:: reset_tables ( & db) . await ?;
90- info ! ( "DB Reset" ) ;
91110 }
92111
93112 let app = Router :: new ( )
@@ -123,8 +142,20 @@ async fn main() -> anyhow::Result<()> {
123142 )
124143 . with_state ( Arc :: new ( UsrState {
125144 db,
126- new_orders_webhook : DiscordWebhook :: new ( config. new_orders_webhook ) ?,
127- order_updates_webhook : DiscordWebhook :: new ( config. order_updates_webhook ) ?,
145+ new_orders_webhook : {
146+ if let Some ( new_orders_webhook) = config. new_orders_webhook {
147+ Some ( DiscordWebhook :: new ( new_orders_webhook) ?)
148+ } else {
149+ None
150+ }
151+ } ,
152+ order_updates_webhook : {
153+ if let Some ( order_updates_webhook) = config. order_updates_webhook {
154+ Some ( DiscordWebhook :: new ( order_updates_webhook) ?)
155+ } else {
156+ None
157+ }
158+ } ,
128159 } ) ) ;
129160
130161 default_provider ( )
0 commit comments