api: fetch care actions for moods and triggers
Pedro Lucas Porcellis porcellis@eletrotupi.com · 4 months ago
4e6e379351e597470bb29f5b250f14df1d6b74f5 Browse filesParents
da89e5eChanged files
2
Additions
+16
Deletions
0
api/src/services/mood.service.ts
1 1
import { prisma } from "@app/lib/prisma";
2 2
import { Mood } from "@prisma/client";
3 3
import { rollingPeriod } from "@app/lib/queue/processors/insights/utils";
4 4
import { InsightJobName } from "@app/lib/queue/types";
5 5
import { getQueue } from "@app/lib/queue";
88 88
moodComponents: true,
89 89
triggerLinks: {
90 90
include: { trigger: true },
91 91
orderBy: { linkedAt: 'desc' },
92 92
},
93 +
careActions: {
94 +
include: {
95 +
medicineLog: { include: { regimen: true } },
96 +
appointment: true,
97 +
activity: true,
98 +
},
99 +
orderBy: { moment: 'desc' },
100 +
},
93 101
},
94 102
});
95 103
};
96 104
97 105
export const destroyMoodById = async (
141 149
removeOnFail: true,
142 150
},
143 151
},
144 152
]);
145 153
};
api/src/services/trigger.service.ts
1 1
import { prisma } from '@app/lib/prisma';
2 2
import { Trigger } from '@prisma/client';
3 3
4 4
import { CreateTriggerInput, UpdateTriggerInput } from '@app/schemas';
5 5
import { rollingPeriod } from "@app/lib/queue/processors/insights/utils";
85 85
include: {
86 86
moodLinks: {
87 87
include: { mood: { include: { moodComponents: true } } },
88 88
orderBy: { linkedAt: 'desc' },
89 89
},
90 +
careActions: {
91 +
include: {
92 +
medicineLog: { include: { regimen: true } },
93 +
appointment: true,
94 +
activity: true,
95 +
},
96 +
orderBy: { moment: 'desc' },
97 +
},
90 98
},
91 99
});
92 100
}
93 101
94 102
export const updateTriggerById = async (
116 124
removeOnComplete: true,
117 125
removeOnFail: true,
118 126
}
119 127
);
120 128
}