feat(gamification): expand badge tiers and count only outgoing likes
This commit is contained in:
@@ -24,19 +24,22 @@ ACTIVITY_BADGES = {
|
||||
{"threshold": 25, "label": "چهره آشنای رویدادها", "description": "حضور تأییدشده در بیستوپنج رویداد"},
|
||||
),
|
||||
"posts": (
|
||||
{"threshold": 1, "label": "نویسنده انجمن", "description": "انتشار یا همنویسندگی یک نوشته"},
|
||||
{"threshold": 5, "label": "نویسنده فعال", "description": "انتشار یا همنویسندگی پنج نوشته"},
|
||||
{"threshold": 10, "label": "نویسنده برجسته", "description": "انتشار یا همنویسندگی ده نوشته"},
|
||||
{"threshold": 1, "label": "نویسنده انجمن", "description": "۱ نوشته منتشرشده"},
|
||||
{"threshold": 5, "label": "نویسنده فعال", "description": "۵ نوشته منتشرشده"},
|
||||
{"threshold": 10, "label": "نویسنده برجسته", "description": "۱۰ نوشته منتشرشده"},
|
||||
{"threshold": 25, "label": "نویسنده پیشرو", "description": "۲۵ نوشته منتشرشده"},
|
||||
),
|
||||
"comments": (
|
||||
{"threshold": 1, "label": "آغاز گفتوگو", "description": "۱ دیدگاه یا پاسخ تأییدشده"},
|
||||
{"threshold": 5, "label": "اهل گفتوگو", "description": "پنج دیدگاه یا پاسخ تأییدشده"},
|
||||
{"threshold": 20, "label": "همراه گفتوگو", "description": "بیست دیدگاه یا پاسخ تأییدشده"},
|
||||
{"threshold": 50, "label": "صدای اثرگذار", "description": "پنجاه دیدگاه یا پاسخ تأییدشده"},
|
||||
),
|
||||
"likes": (
|
||||
{"threshold": 10, "label": "دستگرم", "description": "ده پسند دادهشده یا دریافتشده"},
|
||||
{"threshold": 50, "label": "محبوب انجمن", "description": "پنجاه پسند دادهشده یا دریافتشده"},
|
||||
{"threshold": 100, "label": "الهامبخش", "description": "صد پسند دادهشده یا دریافتشده"},
|
||||
{"threshold": 1, "label": "نخستین لایک", "description": "نخستین لایک روی یک نوشته"},
|
||||
{"threshold": 10, "label": "دستگرم", "description": "ده لایک روی نوشتهها"},
|
||||
{"threshold": 50, "label": "محبوب انجمن", "description": "پنجاه لایک روی نوشتهها"},
|
||||
{"threshold": 100, "label": "الهامبخش", "description": "صد لایک روی نوشتهها"},
|
||||
),
|
||||
}
|
||||
|
||||
@@ -86,7 +89,7 @@ def earned_badges(total_points: int, activity_counts: dict[str, int]) -> list[di
|
||||
|
||||
for category, levels in ACTIVITY_BADGES.items():
|
||||
count = max(0, int(activity_counts.get(category, 0)))
|
||||
badge_prefix = "post" if category == "posts" else category
|
||||
badge_prefix = {"posts": "post", "comments": "comment"}.get(category, category)
|
||||
for badge_level in levels:
|
||||
threshold = badge_level["threshold"]
|
||||
if count >= threshold:
|
||||
|
||||
Reference in New Issue
Block a user