Skip to content

Commit 818ce22

Browse files
Seluj78supalarry
authored andcommitted
Updated recommendations to skip bots
1 parent 1cbcf56 commit 818ce22

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

backend/PyMatcha/models/user.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class User(Model):
6363
is_confirmed = Field(bool)
6464
confirmed_on = Field(datetime.datetime, fmt="%Y-%m-%d %H:%M:%S")
6565
previous_reset_token = Field(str)
66+
skip_recommendations = Field(bool)
6667

6768
@staticmethod
6869
def create(
@@ -83,6 +84,7 @@ def create(
8384
is_profile_completed: bool = False,
8485
is_confirmed: bool = False,
8586
confirmed_on: datetime.datetime = None,
87+
skip_recommendations: bool = False,
8688
) -> User:
8789
# Check email availability
8890
if User.get(email=email):
@@ -136,6 +138,7 @@ def create(
136138
is_confirmed=is_confirmed,
137139
confirmed_on=confirmed_on,
138140
previous_reset_token=None,
141+
skip_recommendations=skip_recommendations,
139142
)
140143
new_user.save()
141144
logging.debug("New user {} created".format(new_user.email))
@@ -175,6 +178,7 @@ def register(email: str, username: str, password: str, first_name: str, last_nam
175178
is_confirmed=False,
176179
confirmed_on=None,
177180
previous_reset_token=None,
181+
skip_recommendations=False,
178182
)
179183
new_user.save()
180184
logging.debug("New user {} created".format(new_user.email))

backend/PyMatcha/utils/tables.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ def _create_user_table(db):
4848
is_online BOOLEAN DEFAULT (FALSE),
4949
is_profile_completed BOOLEAN DEFAULT (FALSE),
5050
is_confirmed BOOLEAN DEFAULT (FALSE),
51-
confirmed_on DATETIME DEFAULT NULL
51+
confirmed_on DATETIME DEFAULT NULL,
52+
skip_recommendations BOOLEAN DEFAULT (FALSE)
5253
) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci ;
5354
"""
5455
)

backend/PyMatcha/utils/tasks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,9 @@ def update_offline_users():
107107
@celery.task
108108
def update_user_recommendations():
109109
count = 0
110-
for user_to_update in User.select_all():
110+
for user_to_update in User.get_multis(skip_recommendations=False):
111111
create_user_recommendations(user_to_update)
112+
count += 1
112113
return f"Successfully updated recommendations for {count} users."
113114

114115

mysql_dump/users-dump.sql

Lines changed: 6 additions & 5 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)