Skip to content

Commit

Permalink
exclude unapproved users from get_one_one_match
Browse files Browse the repository at this point in the history
  • Loading branch information
arthtyagi committed Nov 27, 2022
1 parent 11a3fca commit a41cbd2
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 23 deletions.
48 changes: 26 additions & 22 deletions apps/server/social/ml/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions apps/server/social/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions apps/server/social/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion nixpacks.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit a41cbd2

Please sign in to comment.