Skip to content

Commit 5584f61

Browse files
authored
Merge pull request #450 from Seluj78/chore/changed-timings
Added random scores for bots
2 parents 952cb81 + 2dc1c54 commit 5584f61

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

backend/PyMatcha/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@
210210

211211
import PyMatcha.utils.tasks # noqa
212212
import PyMatcha.utils.jwt_callbacks # noqa
213+
from PyMatcha.utils.tasks import set_random_scores_for_bots
213214

214215

215216
@application.route("/")
@@ -242,3 +243,6 @@ def site_map():
242243
links.append(f"{methods} {url}".split("?")[0])
243244
# links is now a list of url, endpoint tuples
244245
return jsonify(links), 200
246+
247+
248+
set_random_scores_for_bots.delay()

backend/PyMatcha/utils/bot_actions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ def decide_bot_action(bot_user: User):
151151
recommendations = _get_recommendations(bot_user, ignore_bots=True)
152152

153153
# The bot will first view 0 to 3 profiles
154-
for _ in range(0, randrange(0, 3)):
154+
for _ in range(1, randrange(1, 3)):
155155
_botaction_view(bot_user, recommendations)
156156

157157
# The bot will then like 0 to 2 profiles
158-
for _ in range(0, randrange(0, 2)):
158+
for _ in range(1, randrange(1, 2)):
159159
_botaction_like(bot_user, recommendations)
160160

161161
matches = bot_user.get_matches()

backend/PyMatcha/utils/tasks.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import datetime
22
import json
33
import logging
4+
import random
45
from math import ceil
56

67
from PyMatcha import celery
@@ -32,7 +33,7 @@ def setup_periodic_tasks(sender, **kwargs):
3233
sender.add_periodic_task(
3334
600, calc_search_min_max.s(), name="Update Minimum and Maximum scores and ages for search every 10 minutes"
3435
)
35-
sender.add_periodic_task(180, random_bot_action.s(), name="Bots will do random actions")
36+
sender.add_periodic_task(120, random_bot_action.s(), name="Bots will do random actions")
3637

3738

3839
@celery.task
@@ -170,3 +171,11 @@ def bot_respond_to_message(bot_id: int, from_id: int, message_content: str):
170171

171172
logging.debug(f"Bot {bot_id} successfully replied to {from_id}")
172173
return f"Bot {bot_id} successfully replied to {from_id}"
174+
175+
176+
@celery.task
177+
def set_random_scores_for_bots():
178+
for user in User.get_multis(is_bot=True):
179+
user.heat_score = random.randint(0, 150)
180+
user.save()
181+
return "Successfully Added random scores to bot"

0 commit comments

Comments
 (0)