Skip to content

Commit

Permalink
Fix empty change message on start
Browse files Browse the repository at this point in the history
  • Loading branch information
wh0o7 committed Sep 9, 2023
1 parent 2cb9b26 commit a7894c4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions TeachersTimetable/Services/ParseService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public class ParseService : IParseService
private static string LastDayHtmlContent { get; set; }
private static string LastWeekHtmlContent { get; set; }

public ParseService(IMongoService mongoService, IBotService botService, IFirefoxService firefoxService,
public ParseService(IMongoService mongoService, IBotService botService, IFirefoxService firefoxService,
IDistributionService distributionService)
{
this._mongoService = mongoService;
Expand Down Expand Up @@ -274,7 +274,7 @@ public async Task ParseDay()
teacherInfo.Lessons = teacherInfo.Lessons.OrderBy(l => l.Index).ToList();
var teacherInfoFromTimetable =
Timetable.LastOrDefault()?.TeacherInfos.FirstOrDefault(t => t.Name == teacherInfo.Name);

if (teacherInfoFromTimetable is null || teacherInfoFromTimetable.Equals(teacherInfo)) continue;
teacherUpdatedList.Add(teacherInfo.Name);
try
Expand All @@ -283,7 +283,7 @@ public async Task ParseDay()
new SendMessageArgs(0, $"Расписание у группы {teacherInfo.Name}"));

var userList = (await this._mongoService.Database.GetCollection<User>("Users")
.FindAsync(u => u.Teacher != null && u.Notifications && u.Teacher == teacherInfo.Name)).ToList();
.FindAsync(u => u.Teacher != null && u.Notifications && u.Teacher == teacherInfo.Name)).ToList();

notificationUsersList.AddRange(userList);
}
Expand All @@ -293,7 +293,9 @@ public async Task ParseDay()
}
}

_ = this._botService.SendAdminMessageAsync(new SendMessageArgs(0, $"There's been a schedule change with the teachers: {string.Join(',', teacherUpdatedList)}"));
if (teacherUpdatedList.Count != 0)
_ = this._botService.SendAdminMessageAsync(new SendMessageArgs(0,
$"There's been a schedule change with the teachers: {string.Join(',', teacherUpdatedList)}"));
Timetable.Clear();
Timetable.Add(new()
{
Expand Down

0 comments on commit a7894c4

Please sign in to comment.