refactor(DiaryDateActivityService): improve orderId calculation logic for group activities
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 44s
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 44s
- Updated the logic for determining the maximum orderId to handle cases with and without groupId more clearly. - Enhanced code readability by consolidating the where clause for fetching max orderId based on group context.
This commit is contained in:
@@ -64,11 +64,17 @@ class DiaryDateActivityService {
|
||||
}
|
||||
}
|
||||
|
||||
const maxOrderId = await DiaryDateActivity.max('orderId', {
|
||||
where: {
|
||||
const maxOrderWhere = restData.groupId
|
||||
? {
|
||||
diaryDateId: data.diaryDateId,
|
||||
groupId: restData.groupId
|
||||
}
|
||||
: {
|
||||
// Globale Aktivitäten bei "Alle" sollen am Ende des gesamten Tagesplans landen.
|
||||
diaryDateId: data.diaryDateId
|
||||
};
|
||||
const maxOrderId = await DiaryDateActivity.max('orderId', {
|
||||
where: maxOrderWhere
|
||||
});
|
||||
const newOrderId = maxOrderId !== null ? maxOrderId + 1 : 1;
|
||||
restData.orderId = newOrderId;
|
||||
|
||||
Reference in New Issue
Block a user