feat: add shared task assignments and quick win sorting
This commit is contained in:
@@ -4,7 +4,7 @@ import json
|
||||
from collections import defaultdict
|
||||
from datetime import date, datetime, time, timedelta
|
||||
|
||||
from sqlalchemy import and_
|
||||
from sqlalchemy import and_, or_
|
||||
|
||||
from ..extensions import db
|
||||
from ..models import BadgeDefinition, MonthlyScoreSnapshot, TaskInstance, User, UserBadge
|
||||
@@ -92,7 +92,7 @@ def _completion_metrics(user: User) -> dict[str, int]:
|
||||
metrics["on_time_tasks_completed"] += 1
|
||||
if completion_day <= task.due_date - timedelta(days=1):
|
||||
metrics["early_tasks_completed"] += 1
|
||||
if task.assigned_user_id and task.assigned_user_id != user.id:
|
||||
if task.assigned_user_ids and user.id not in task.assigned_user_ids:
|
||||
metrics["foreign_tasks_completed"] += 1
|
||||
max_points = max(max_points, task.points_awarded)
|
||||
|
||||
@@ -127,7 +127,10 @@ def _user_had_clean_month(user_id: int, year: int, month: int) -> bool:
|
||||
start_date = date(year, month, 1)
|
||||
end_date = (month_bounds(year, month)[1] - timedelta(days=1)).date()
|
||||
tasks = TaskInstance.query.filter(
|
||||
TaskInstance.assigned_user_id == user_id,
|
||||
or_(
|
||||
TaskInstance.assigned_user_id == user_id,
|
||||
TaskInstance.assigned_user_secondary_id == user_id,
|
||||
),
|
||||
TaskInstance.due_date >= start_date,
|
||||
TaskInstance.due_date <= end_date,
|
||||
).all()
|
||||
|
||||
Reference in New Issue
Block a user