diff --git a/backend/crm/celery.py b/backend/crm/celery.py index 0e940b7c..95cf89ff 100644 --- a/backend/crm/celery.py +++ b/backend/crm/celery.py @@ -49,9 +49,9 @@ app.conf.beat_schedule = { "task": "opportunity.tasks.check_stale_opportunities", "schedule": crontab(hour=8, minute=0), }, - # Check goal milestones and send notifications - daily at 9 AM + # Check goal milestones and send notifications - daily at 9:15 AM "check-goal-milestones": { "task": "opportunity.tasks.check_goal_milestones", - "schedule": crontab(hour=9, minute=0), + "schedule": crontab(hour=9, minute=15), }, } diff --git a/backend/opportunity/tests/test_sales_goals.py b/backend/opportunity/tests/test_sales_goals.py index f6612161..d03af76d 100644 --- a/backend/opportunity/tests/test_sales_goals.py +++ b/backend/opportunity/tests/test_sales_goals.py @@ -518,4 +518,5 @@ class TestGoalMilestoneTask: # Should not trigger 90% (only at 60%) assert goal.milestone_90_notified is False # Already had 50% notified, should not re-send - # mock_send may be called for other things, but milestone_50 was already True + assert goal.milestone_50_notified is True + assert mock_send.call_count == 0 diff --git a/backend/opportunity/views/goal_views.py b/backend/opportunity/views/goal_views.py index 518dc908..182d5210 100644 --- a/backend/opportunity/views/goal_views.py +++ b/backend/opportunity/views/goal_views.py @@ -62,7 +62,7 @@ class SalesGoalListView(APIView, LimitOffsetPagination): "goals": serializer.data, "goals_count": total_count, "offset": offset, - "per_page": 10, + "per_page": self.get_limit(request), } ) @@ -181,6 +181,7 @@ class SalesGoalLeaderboardView(APIView): leaderboard = [] for goal in goals: + # compute_progress() results are cached on the instance progress = goal.compute_progress() if goal.target_value and goal.target_value != 0: percent = min( diff --git a/frontend/src/lib/components/dashboard/GoalProgress.svelte b/frontend/src/lib/components/dashboard/GoalProgress.svelte index eddd026c..83905083 100644 --- a/frontend/src/lib/components/dashboard/GoalProgress.svelte +++ b/frontend/src/lib/components/dashboard/GoalProgress.svelte @@ -52,7 +52,7 @@
{goal.name} - {goal.progress_percent}% + {goal.progress_percent ?? 0}%
openEditDrawer(goal)} + onkeydown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); openEditDrawer(goal); } }} >