Add initiator approvals to daily reminder #116

Merged
romanskijdev merged 1 commits from fix-permissions into main 2026-08-25 08:52:56 +03:00
1 changed files with 15 additions and 1 deletions

View File

@ -140,6 +140,17 @@ func (dr *DailyReminder) sendReminderToUser(bot *tgbotapi.BotAPI, ctx context.Co
}
revisionsCount := len(revisions)
myPendingApprovals, _, err := dr.ipc.Database.Approval.GetApprovalsListDB(ctx, typescore.ListDbOptions{
Filtering: &typescore.Approval{
InitiatorID: &userID,
Status: utilscore.PointerToString("pending"),
},
})
if err != nil {
logrus.Errorf("DailyReminder: GetApprovalsListDB (my pending) for user=%d err=%v", userID, err)
}
myPendingCount := len(myPendingApprovals)
tasks, _, err := dr.ipc.Database.ApprovalTasks.GetApprovalTasksListDB(ctx, typescore.ListDbOptions{
Filtering: &typescore.ApprovalTask{
ExecutorID: &userID,
@ -174,7 +185,7 @@ func (dr *DailyReminder) sendReminderToUser(bot *tgbotapi.BotAPI, ctx context.Co
approvalsCount := dr.countPendingApprovals(ctx, steps, additionalApprovers)
hasPersonalItems := revisionsCount > 0 || tasksCount > 0 || approvalsCount > 0
hasPersonalItems := revisionsCount > 0 || tasksCount > 0 || approvalsCount > 0 || myPendingCount > 0
logrus.Infof("DailyReminder: userID=%d telegramID=%d — revisions=%d tasks=%d approvals=%d hasPersonalItems=%v absentTodayCount=%d",
userID, telegramID, revisionsCount, tasksCount, approvalsCount, hasPersonalItems, len(absentToday))
@ -186,6 +197,9 @@ func (dr *DailyReminder) sendReminderToUser(bot *tgbotapi.BotAPI, ctx context.Co
text := "☀️ <b>Доброе утро! Ежедневная сводка</b>\n\n"
if myPendingCount > 0 {
text += fmt.Sprintf("Ваших заявок на согласовании: <b>%d</b>\n", myPendingCount)
}
if revisionsCount > 0 {
text += fmt.Sprintf("Заявок на доработке: <b>%d</b>\n", revisionsCount)
}