feat: warn on the dashboard when a queen is 3+ years old
Queen.hatchYear was already captured but never used anywhere - no signal existed for "this colony's queen is overdue for evaluation or replacement," despite that being one of the most common productivity and swarming risk factors in beekeeping. Adds an OLD_QUEEN dashboard alert alongside the existing overdue-task/swarm-check ones, flagging any active colony whose current queen has completed 3+ seasons. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
1 parent
8c4ae64e76
commit
edf13d3ae4
4 files changed
+104
-26
No files matched your search
@@ -107,4 +107,35 @@ describe('DashboardService', () => {
|
||||
|
||||
expect(alerts).toHaveLength(0);
|
||||
});
|
||||
|
||||
describe('OLD_QUEEN', () => {
|
||||
it('flags a colony whose queen is at least 3 years old', async () => {
|
||||
prisma.colony.findMany
|
||||
.mockResolvedValueOnce([]) // attentionColonies
|
||||
.mockResolvedValueOnce([
|
||||
{ id: 'colony-1', code: 'V-001', currentQueen: { hatchYear: 2020 } },
|
||||
]);
|
||||
|
||||
const alerts = await service.alerts();
|
||||
|
||||
expect(alerts).toHaveLength(1);
|
||||
expect(alerts[0].type).toBe('OLD_QUEEN');
|
||||
expect(alerts[0].relatedId).toBe('colony-1');
|
||||
});
|
||||
|
||||
it('does not flag a queen younger than the threshold', async () => {
|
||||
const currentYear = new Date().getFullYear();
|
||||
prisma.colony.findMany.mockResolvedValueOnce([]).mockResolvedValueOnce([
|
||||
{
|
||||
id: 'colony-1',
|
||||
code: 'V-001',
|
||||
currentQueen: { hatchYear: currentYear },
|
||||
},
|
||||
]);
|
||||
|
||||
const alerts = await service.alerts();
|
||||
|
||||
expect(alerts).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user