refactor: confirm skill rarity at fifty xp
This commit is contained in:
parent
53871a8f37
commit
dec526898e
@ -29,6 +29,7 @@ SKILL_RANKS = (
|
||||
)
|
||||
|
||||
ENDORSEMENT_COOLDOWN_DAYS = 90
|
||||
RARITY_CONFIRMATION_EXPERIENCE = 50
|
||||
TASK_ASSIGNEE_SKILL_EXPERIENCE = 30
|
||||
TASK_PARTICIPANT_SKILL_EXPERIENCE = 15
|
||||
|
||||
@ -40,7 +41,7 @@ def skill_queryset_with_rarity(queryset=None):
|
||||
"employee_progresses",
|
||||
filter=Q(
|
||||
employee_progresses__is_active=True,
|
||||
employee_progresses__experience__gte=100,
|
||||
employee_progresses__experience__gte=RARITY_CONFIRMATION_EXPERIENCE,
|
||||
employee_progresses__employee__is_active=True,
|
||||
employee_progresses__employee__is_hidden_in_ui=False,
|
||||
),
|
||||
@ -108,7 +109,7 @@ def confirmed_holder_count(skill: Skill) -> int:
|
||||
EmployeeSkillProgress.objects.filter(
|
||||
skill=skill,
|
||||
is_active=True,
|
||||
experience__gte=100,
|
||||
experience__gte=RARITY_CONFIRMATION_EXPERIENCE,
|
||||
employee__is_active=True,
|
||||
employee__is_hidden_in_ui=False,
|
||||
employee__skills=skill,
|
||||
|
||||
@ -11,9 +11,11 @@ from employees.models import (
|
||||
)
|
||||
from employees.services.skill_progress import (
|
||||
award_task_skill_experience,
|
||||
confirmed_holder_count,
|
||||
rank_payload,
|
||||
rarity_payload,
|
||||
revoke_task_skill_experience,
|
||||
skill_queryset_with_rarity,
|
||||
)
|
||||
from tasks.models import Task, TaskBoard, TaskColumn
|
||||
from tests.conftest import _unique_email, _unique_phone
|
||||
@ -112,6 +114,24 @@ def test_skill_rank_and_rarity_boundaries():
|
||||
assert rarity_payload(25)["rarity"] == "common"
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_skill_rarity_counts_holders_from_fifty_experience():
|
||||
employee = _mk_user()
|
||||
skill = Skill.objects.create(name="Redis")
|
||||
employee.skills.add(skill)
|
||||
progress = EmployeeSkillProgress.objects.get(employee=employee, skill=skill)
|
||||
|
||||
progress.experience = 49
|
||||
progress.save(update_fields=["experience", "updated_at"])
|
||||
assert confirmed_holder_count(skill) == 0
|
||||
|
||||
progress.experience = 50
|
||||
progress.save(update_fields=["experience", "updated_at"])
|
||||
assert confirmed_holder_count(skill) == 1
|
||||
annotated_skill = skill_queryset_with_rarity(Skill.objects.filter(pk=skill.pk)).get()
|
||||
assert annotated_skill.confirmed_holders == 1
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_adding_skill_creates_active_progress(api_client):
|
||||
actor = _mk_user()
|
||||
|
||||
@ -1074,6 +1074,9 @@ export function ProfileSkillsInline({
|
||||
<p className="app-text-muted mt-1 text-xs leading-relaxed">
|
||||
Редкость относится к самому навыку и показывает, насколько редко он встречается среди подтверждённых обладателей в компании. Ранг при этом остаётся личным для каждого сотрудника.
|
||||
</p>
|
||||
<p className="app-text-muted mt-1 text-[11px] leading-relaxed">
|
||||
Сотрудник считается подтверждённым обладателем навыка после достижения 50 XP — ранг «Бронза» для этого не требуется.
|
||||
</p>
|
||||
<div className="mt-2 flex flex-wrap gap-1.5">
|
||||
{[
|
||||
{ rarity: "legendary" as const, label: "Легендарный · 1" },
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user