Skip to content

Commit 7c8f991

Browse files
Cron for C4GT Community (#235)
* cron poc * code completion in cron * create and update checks in adding contributors to a ticket * sending report to discord bot added * Cron Fixes Mentor and Contributor * logs and await added in add_contributors * user activity calling type changed * Cron Fixes * Updated requirements.txt * code changes for cron token generation * changes in requirements.txt * jwt generator and access token changes * reading pem file bug fix * reading pem file bug fix * reading pem file bug fix * reading pem file bug fix * reading pem file bug fix * reading pem file bug fix * reading pem file bug fix * reading pem file bug fix * reading pem file bug fix * reading pem file bug fix * reading pem file bug fix * updated jwt token generator for deploy testing * updated jwt token generator for deploy testing * updated requirements.txt for deploy testing * updated requirements.txt for deploy testing * updated token generator for deploy testing * remove jwt to resolve conflict * trying with local path of pem file to resolve conflict * updating docker file for pem file * cleaner * cleaner * Removed submodule * Readded submodule * Updated Pem location * Testing - Pem and client id * pagination and state added to get all apis * pagination and state added to get all apis * pagination and state added to get all apis * 1. Added Access token based requests within handlers. 2. Fixed Issue handler and Pr Handler for cron * Removed submodule * Readded submodule * 1. Mentors data now being fetched from db 2. Since added in comments fetching * 1. Removed Bot Commenting * 1. Removed Bot Commenting 2. Added Logger * 1. Minor fixes for prod deployment 2. Discord Report commented --------- Co-authored-by: jaanbaaz <[email protected]> Co-authored-by: jaanbaaz <[email protected]>
1 parent 5c37add commit 7c8f991

13 files changed

+844
-176
lines changed

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ RUN --mount=type=ssh git submodule update --init --recursive
1515

1616
ARG REPOSITORY_MONITOR_APP_PK_PEM
1717

18-
RUN echo $REPOSITORY_MONITOR_APP_PK_PEM > /app/utils/repository_monitor_app_pk.pem
18+
RUN echo "$REPOSITORY_MONITOR_APP_PK_PEM" | sed 's/\\n/\n/g' > /app/utils/repository_monitor_app_pk.pem
1919

2020
EXPOSE 5000
2121
ENV FLASK_APP=app.py

app.py

+17-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from quart_cors import cors
2727
from utils.migrate_tickets import MigrateTickets
2828
from utils.migrate_users import MigrateContributors
29+
from cronjob.cronjob import CronJob
2930

3031
scheduler = AsyncIOScheduler()
3132

@@ -247,7 +248,7 @@ async def register(discord_userdata):
247248
async def event_handler():
248249
try:
249250
data = await request.json
250-
print('data is ', data)
251+
logger.info(f"Webhook Recieved - {data}")
251252
secret_key = os.getenv("WEBHOOK_SECRET")
252253

253254
verification_result, error_message = await verify_github_webhook(request,secret_key)
@@ -258,7 +259,7 @@ async def event_handler():
258259

259260
return data
260261
except Exception as e:
261-
logger.info(e)
262+
logger.error(e)
262263
return "Server Error"
263264

264265

@@ -409,5 +410,18 @@ async def add_issue_id_pr():
409410
return 'failed'
410411

411412

413+
@app.before_serving
414+
async def start_scheduler():
415+
scheduler.add_job(CronJob().main, "cron", hour=2, minute=0)
416+
scheduler.start()
417+
418+
419+
@app.route('/trigger-cron')
420+
async def trigger_cron():
421+
cronjob = CronJob()
422+
# return await cronjob.main()
423+
asyncio.create_task(cronjob.main())
424+
return 'cron started'
425+
412426
if __name__ == '__main__':
413-
app.run()
427+
app.run()

0 commit comments

Comments
 (0)