Skip to content

Commit

Permalink
stubbing out table cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tblanarik committed Sep 28, 2024
1 parent b757c53 commit da043f0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cleanup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import logging

def cleanup():
logging.info("Executing table cleanup function")
14 changes: 13 additions & 1 deletion function_app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import azure.functions as func
import spotbot as sb
import cleanup
import logging

app = func.FunctionApp(http_auth_level=func.AuthLevel.FUNCTION)
Expand All @@ -12,4 +13,15 @@ def spotbot(req: func.HttpRequest) -> func.HttpResponse:
logging.error(f"Exception occurred: {_excpt}")
return func.HttpResponse(body=f"Exception occurred: {_excpt}", status_code=500)
else:
return func.HttpResponse(status_code=202)
return func.HttpResponse(status_code=202)

@app.function_name(name="tablecleanup")
@app.schedule(schedule="0 8 * * *",
arg_name="tablecleanup",
run_on_startup=False)
def table_cleanup(timer: func.TimerRequest) -> None:
cleanup.cleanup()

@app.route(route="manualcleanup", methods=[func.HttpMethod.POST])
def manual_cleanup(req: func.HttpRequest) -> func.HttpResponse:
cleanup.cleanup()

0 comments on commit da043f0

Please sign in to comment.