@@ -3,39 +3,25 @@ import {
33 TaskWithAssignees ,
44 endOfDayTomorrow ,
55 getTeamFromTaskAssignees ,
6+ startOfDayTomorrow ,
67 usersToSlackPings
78} from '../utils/notifications.utils' ;
89import { sendMessage } from '../integrations/slack' ;
9- import WorkPackagesService from './work-packages.services' ;
10- import { addWeeksToDate , daysBetween } from 'shared' ;
11- import { HttpException } from '../utils/errors.utils' ;
10+ import { daysBetween } from 'shared' ;
1211import { buildDueString } from '../utils/slack.utils' ;
1312
1413export default class NotificationsService {
15- static async sendDailySlackNotifications ( ) {
16- await NotificationsService . sendTaskDeadlineSlackNotifications ( ) ;
17- const date = new Date ( ) ;
18- if ( date . getDay ( ) === 1 ) {
19- const nextWeek = addWeeksToDate ( date , 1 ) ;
20- const ADMIN = process . env . ADMIN_USER_ID ;
21- const admin = await prisma . user . findUnique ( { where : { userId : ADMIN } } ) ;
22- if ( ! admin ) throw new HttpException ( 404 , 'Admin user not found' ) ;
23- const organizations = await prisma . organization . findMany ( ) ;
24- for ( const organization of organizations ) {
25- await WorkPackagesService . slackMessageUpcomingDeadlines ( admin , nextWeek , organization . organizationId ) ;
26- }
27- }
28- }
29-
3014 /**
31- * Sends the task deadline slack notifications for all tasks with a deadline of tomorrow or before that are not done
15+ * Sends the task deadline slack notifications for all tasks with a deadline of tomorrow
3216 */
3317 static async sendTaskDeadlineSlackNotifications ( ) {
18+ const startOfDay = startOfDayTomorrow ( ) ;
3419 const endOfDay = endOfDayTomorrow ( ) ;
3520
3621 const tasks = await prisma . task . findMany ( {
3722 where : {
3823 deadline : {
24+ gte : startOfDay ,
3925 lt : endOfDay
4026 } ,
4127 status : {
0 commit comments