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') ...@@ -13,6 +13,8 @@ development_mode = os.getenv('PYCHARM_HOSTED')
def main(): def main():
log = logging.getLogger('wrapper') log = logging.getLogger('wrapper')
messages_seen = []
log.info("Running main") log.info("Running main")
host = 'localhost' if development_mode else 'redis.wendt.vpn' host = 'localhost' if development_mode else 'redis.wendt.vpn'
try: try:
...@@ -40,8 +42,15 @@ def main(): ...@@ -40,8 +42,15 @@ def main():
subject = data["headers"]["subject"] subject = data["headers"]["subject"]
log.info(f"Subject: {subject}") log.info(f"Subject: {subject}")
if "III Grading Required" in subject: if "III Grading Required" in subject:
log.info("Subject found - let's go snatching!") if len(messages_seen) == 0:
snatch_grading_work() 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: else:
log.info("Ignoring this email") log.info("Ignoring this email")
except Exception as e: 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