diff --git a/apps/server/social/ml/match.py b/apps/server/social/ml/match.py index a6ef6c8..6a8d536 100644 --- a/apps/server/social/ml/match.py +++ b/apps/server/social/ml/match.py @@ -9,7 +9,7 @@ from sklearn.preprocessing import StandardScaler from sklearn.preprocessing import LabelEncoder from social.models import SocialProfile -from users.models import User +from users.models import User, UserStatus User = get_user_model() @@ -92,34 +92,38 @@ def get_indirect_match(user, number_of_matches_to_make=1): def get_one_one_match(user, number_of_matches_to_make=1): indirect_matching = False logged_in_social_profile = SocialProfile.objects.get(user=user) + + base_profiles = ( + SocialProfile.objects.exclude(user=user) + .filter(user__userstatus__approved=True) + .exclude( + available_always_off=True + ) # for users who just logged in and haven't set their availability yet + .exclude(available_this_week=False) + .exclude(blocked=logged_in_social_profile) + .exclude(shadowed=logged_in_social_profile) + .exclude(circle=logged_in_social_profile) + .exclude(skipped=logged_in_social_profile) + .values_list( + "user", + "idea_status", + "video_call_friendly", + "raw_xp", + "location", + "timezone", + ) + ) + all_profiles = [ transform_variables_profile(social_profile) - for social_profile in list( - SocialProfile.objects.exclude(user=user) - .exclude( - available_always_off=True - ) # for users who just logged in and haven't set their availability yet - .exclude(available_this_week=False) - .exclude(blocked=logged_in_social_profile) - .exclude(shadowed=logged_in_social_profile) - .exclude(circle=logged_in_social_profile) - .exclude(skipped=logged_in_social_profile) - .values_list( - "user", - "idea_status", - "video_call_friendly", - "raw_xp", - "location", - "timezone", - ) - ) + for social_profile in list(base_profiles) ] indirect_all_profiles = [ transform_variables_profile(social_profile) for social_profile in list( - SocialProfile.objects - # .exclude(user=logged_in_user) + SocialProfile.objects.exclude(user=user) + .filter(user__userstatus__approved=True) .exclude( available_always_off=True ) # for users who just logged in and haven't set their availability yet diff --git a/apps/server/social/models.py b/apps/server/social/models.py index 6d23fe9..72d36c6 100644 --- a/apps/server/social/models.py +++ b/apps/server/social/models.py @@ -3,6 +3,8 @@ from django.contrib.auth import get_user_model from django.core.validators import MaxValueValidator, MinValueValidator +from users.models import UserStatus + from timezone_field import TimeZoneField User = get_user_model() diff --git a/apps/server/social/tasks.py b/apps/server/social/tasks.py index 8ac91db..ed5d2ff 100644 --- a/apps/server/social/tasks.py +++ b/apps/server/social/tasks.py @@ -18,12 +18,15 @@ def assign_matches_this_week(): try: + # AVAILABLE SocialProfile.objects.filter(available_always_off=False).update( available_this_week=True ) + # CLEAR for profile in SocialProfile.objects.all(): profile.matches_this_week.clear() profile.save() + # MATCH for social_profile in SocialProfile.objects.filter( available_this_week=True ).all(): diff --git a/nixpacks.toml b/nixpacks.toml index 1152589..fb81fa2 100644 --- a/nixpacks.toml +++ b/nixpacks.toml @@ -9,4 +9,4 @@ cmds = [ "python -m venv /opt/venv && . /opt/venv/bin/activate && pip install po cmd = "cd apps/server && . /opt/venv/bin/activate && ./manage.py collectstatic --noinput" [start] -cmd = "cd apps/server && . /opt/venv/bin/activate && python ./manage.py migrate && python ./manage.py createsu && gunicorn -b :8000 --workers 3 --threads 12 --timeout 600 devclad.wsgi" +cmd = "cd apps/server && . /opt/venv/bin/activate && python ./manage.py migrate && python ./manage.py createsu && gunicorn -b :8000 --workers 3 --threads 12 --timeout 600 --log-level debug devclad.wsgi"