Commit 7b14ae10 authored by Fredrik Wendt's avatar Fredrik Wendt

Make wrapper only snatch every 4th grading work

parent f7c124ec
......@@ -13,6 +13,8 @@ development_mode = os.getenv('PYCHARM_HOSTED')
def main():
log = logging.getLogger('wrapper')
messages_seen = []
log.info("Running main")
host = 'localhost' if development_mode else 'redis.wendt.vpn'
try:
......@@ -40,8 +42,15 @@ def main():
subject = data["headers"]["subject"]
log.info(f"Subject: {subject}")
if "III Grading Required" in subject:
if len(messages_seen) == 0:
log.info("Subject found - let's go snatching!")
snatch_grading_work()
else:
log.info("Not snatching this one, only every 4th")
messages_seen.append(message)
if len(messages_seen) == 4:
log.info("Clearing message log, snatching the next one")
messages_seen = []
else:
log.info("Ignoring this email")
except Exception as e:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment