Skip to content

Commit

Permalink
Maybe fix week notification#2
Browse files Browse the repository at this point in the history
  • Loading branch information
wh0o7 committed Nov 8, 2023
1 parent c965de3 commit 29dc551
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions StudentsTimetable/Services/ParseService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -279,25 +279,26 @@ private async Task ParseWeek()
By.XPath("/html/body/div[1]/div[2]/div/div[2]/div[1]/div/h3"));
var weekIntervalStr = h3[0].Text;
var weekInterval = Utils.ParseDateTimeWeekInterval(weekIntervalStr);
var isIsNewInterval = IsNewInterval;
if (_weekInterval is null || !string.IsNullOrEmpty(weekIntervalStr) && _weekInterval != weekInterval)
{
var isIsNewInterval = IsNewInterval;
IsNewInterval = _weekInterval is not null;
if (_weekInterval is null || _weekInterval[1] is not null && DateTime.Today == _weekInterval[1])
{
_weekInterval = weekInterval;
IsNewInterval = isIsNewInterval != IsNewInterval;
IsNewInterval = false;
Console.WriteLine("New interval is " + weekIntervalStr);
this._botService.SendAdminMessage(new SendMessageArgs(0, "New interval is " + weekIntervalStr));
}

isIsNewInterval = !isIsNewInterval && IsNewInterval;
var tempThHeaders = driver
.FindElement(By.XPath("/html/body/div[1]/div[2]/div/div[2]/div[1]/div/div[1]/table/tbody/tr[1]"))
.FindElements(By.TagName("th"));
_thHeaders = new List<string>();
foreach (var thHeader in tempThHeaders) _thHeaders.Add(new string(thHeader.Text));
}

var table = driver.FindElements(By.XPath("/html/body/div[1]/div[2]/div/div[2]/div[1]/div/div"));
Utils.HideGroupElements(driver, h3);
Utils.HideGroupElements(driver, h2);
Expand Down Expand Up @@ -336,7 +337,7 @@ private async Task ParseWeek()
}
}

if (IsNewInterval)
if (isIsNewInterval)
_ = Task.Run(() =>
{
foreach (var user in notificationUserHashSet)
Expand Down

0 comments on commit 29dc551

Please sign in to comment.