From ffdb5d80e5cefa741c994294dbdfe9650ad869fc Mon Sep 17 00:00:00 2001 From: skandrigi Date: Thu, 28 Nov 2024 23:27:37 -0600 Subject: [PATCH] delete unnecessary meal groups file --- hiss/application/meal_groups.py | 59 --------------------------------- hiss/hiss/celery.py | 5 +-- 2 files changed, 3 insertions(+), 61 deletions(-) delete mode 100644 hiss/application/meal_groups.py diff --git a/hiss/application/meal_groups.py b/hiss/application/meal_groups.py deleted file mode 100644 index ff946ecd..00000000 --- a/hiss/application/meal_groups.py +++ /dev/null @@ -1,59 +0,0 @@ -from django.db import transaction -from models import Application - -NUM_GROUPS = 4 -RESTRICTED_FRONTLOAD_FACTOR = 1.3 - -def assign_food_groups(): - veg_apps = [] - nobeef_apps = [] - nopork_apps = [] - allergy_apps = [] - othernonveg_apps = [] - - applicants = Application.objects.filter(status__in=['A', 'E', 'C']) - - for app in applicants: - if "Vegetarian" in app.dietary_restrictions or "Vegan" in app.dietary_restrictions: - veg_apps.append(app) - elif "No-Beef" in app.dietary_restrictions: - nobeef_apps.append(app) - elif "No-Pork" in app.dietary_restrictions: - nopork_apps.append(app) - elif "Food-Allergy" in app.dietary_restrictions: - allergy_apps.append(app) - else: - othernonveg_apps.append(app) - - restricted_apps = veg_apps + nobeef_apps + nopork_apps + allergy_apps - num_apps = len(restricted_apps) + len(othernonveg_apps) - - group_size = num_apps // NUM_GROUPS - restricted_percent = len(restricted_apps) / num_apps - restricted_target = restricted_percent * RESTRICTED_FRONTLOAD_FACTOR - restricted_per_group = restricted_target * group_size - - groups = [[] for _ in range(NUM_GROUPS)] - group_restricted_count = [0] * NUM_GROUPS - - # Assign restricted applicants - for i in range(NUM_GROUPS): - groups[i] = restricted_apps[:int(restricted_per_group)] - restricted_apps = restricted_apps[int(restricted_per_group):] - group_restricted_count[i] = len(groups[i]) - - # Assign unrestricted applicants - for i in range(NUM_GROUPS): - groups[i] += othernonveg_apps[:group_size - group_restricted_count[i]] - othernonveg_apps = othernonveg_apps[group_size - group_restricted_count[i]:] - groups[-1] += othernonveg_apps - - # Update database with meal groups - with transaction.atomic(): - for i, group in enumerate(groups): - group_letter = chr(65 + i) - for app in group: - app.meal_group = group_letter - app.save() - - return {f"Group {chr(65 + i)}": len(group) for i, group in enumerate(groups)} diff --git a/hiss/hiss/celery.py b/hiss/hiss/celery.py index 56a45d05..af82effb 100644 --- a/hiss/hiss/celery.py +++ b/hiss/hiss/celery.py @@ -1,5 +1,6 @@ from __future__ import absolute_import, unicode_literals import os + from celery import Celery # Set the default Django settings module for the 'celery' program. @@ -14,8 +15,8 @@ app.autodiscover_tasks() # Celery configuration for Redis as the broker and result backend -app.conf.broker_url = os.environ.get('REDIS_URL', 'redis://localhost:6379/0') # Redis as broker -app.conf.result_backend = os.environ.get('REDIS_URL', 'redis://localhost:6379/0') # Redis as result backend +app.conf.broker_url = os.environ.get('REDIS_URL', 'redis://localhost:6379/0') +app.conf.result_backend = os.environ.get('REDIS_URL', 'redis://localhost:6379/0') @app.task(bind=True) def debug_task(self):