You are implementing an in-memory task management system with a set of APIs that evolve over 4 levels. All APIs receive a timestamp: int parameter. Unless otherwise stated, timestamps are integers and can be assumed to be non-decreasing across calls (you may state and rely on this if needed).
Task IDs are generated sequentially as strings:
"task_id_1"
, then
"task_id_2"
, etc.
task_id_2
comes before
task_id_10
).
A task has:
name: str
priority: int
(non-negative,
>= 0
)
Assignments (introduced later) are time-based.
Implement the following:
add_task(self, timestamp: int, name: str, priority: int) -> str
name
and
priority
.
name
and
priority
is allowed; tasks are differentiated by ID.
timestamp
is unused in Level 1 logic; included for API consistency.
update_task(self, timestamp: int, task_id: str, name: str, priority: int) -> bool
name
and
priority
of the task identified by
task_id
.
True
if update succeeds;
False
if
task_id
does not exist.
get_task(self, timestamp: int, task_id: str) -> str | None
task_id
.
name
and
priority
).
None
.
Add the following APIs:
search_tasks(self, timestamp: int, name_filter: str, max_results: int) -> list[str]
name
contains
name_filter
as a
case-sensitive substring
.
max_results
matching
task IDs
.
priority
descending, then
max_results <= 0
, return
[]
.
list_tasks_sorted(self, timestamp: int, limit: int) -> list[str]
limit
task IDs across the system.
priority
descending, then creation order ascending.
Introduce users with quotas and time-windowed assignments.
add_user(self, timestamp: int, user_id: str, quota: int) -> bool
quota
).
True
if added,
False
if
user_id
already exists.
assign_task(self, timestamp: int, task_id: str, user_id: str, finish_time: int) -> bool
task_id
to
user_id
for the time interval
[timestamp, finish_time)
.
t
iff
start_time <= t < finish_time
.
True
if successful; otherwise
False
if:
get_user_tasks(self, timestamp: int, user_id: str) -> list[str]
user_id
at the given
timestamp
.
start_time <= timestamp < finish_time
.
Add completion and overdue queries.
complete_task(self, timestamp: int, task_id: str, user_id: str) -> bool
user_id
at time
timestamp
.
timestamp
.
True
if successful; otherwise
False
if:
timestamp
.
get_overdue_assignments(self, timestamp: int, user_id: str) -> list[str]
user_id
and
expired without completion
.
finish_time <= timestamp
, and
finish_time of that specific assignment
.
Implement the full system so that all levels work together consistently. Clarify any additional assumptions you need (e.g., whether timestamps are non-decreasing, whether a task can be assigned multiple times, and how repeated assignments to the same user/task should behave), but your behavior must remain consistent with the definitions above.