Skip to content

Commit

Permalink
more edt fetch check
Browse files Browse the repository at this point in the history
  • Loading branch information
ghrlt committed Oct 2, 2023
1 parent f49d6fb commit a27b4b4
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 20 deletions.
13 changes: 11 additions & 2 deletions slash_commands/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,18 @@ async def _updateUsers(
wigor = apis.WigorServices()
wigor.login(user[0], user[1])
try:
edt = wigor.fetchAndParse('10/01/2023', toJson=True)
edt = wigor.fetchAndParse('10/02/2023', toJson=True)
except apis.WigorServices.CurrentlyOnHoliday:
continue
try:
edt = wigor.fetchAndParse('10/09/2023', toJson=True)
except apis.WigorServices.CurrentlyOnHoliday:
try:
edt = wigor.fetchAndParse('10/16/2023', toJson=True)
except apis.WigorServices.CurrentlyOnHoliday:
try:
edt = wigor.fetchAndParse('10/23/2023', toJson=True)
except apis.WigorServices.CurrentlyOnHoliday:
continue

for day in edt.keys():
if not edt[day]:
Expand Down
51 changes: 33 additions & 18 deletions views/inappoauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,24 +105,39 @@ async def on_submit(self, interaction: discord.Interaction):
#~ Let's fetch class
wigor = apis.WigorServices()
wigor.login(username, None)
try:
edt = wigor.fetchAndParse('10/01/2023', toJson=True)

for day in edt.keys():
if not edt[day]:
continue

classGrade = edt[day][0]['classGrade']
classLevel = classGrade['level']
classGroup = classGrade['group']

isApprenant = True

except apis.WigorServices.CurrentlyOnHoliday:
classLevel = '?'
classGroup = '?'
isApprenant = False


def fetchAndParse(date: str, toJson: bool):
try:
edt = wigor.fetchAndParse(date, toJson=toJson)

for day in edt.keys():
if not edt[day]:
continue

classGrade = edt[day][0]['classGrade']
classLevel = classGrade['level']
classGroup = classGrade['group']

isApprenant = True

except apis.WigorServices.CurrentlyOnHoliday:
classLevel = '?'
classGroup = '?'
isApprenant = False

return classGrade, classLevel, classGroup, isApprenant

classGrade, classLevel, classGroup, isApprenant = fetchAndParse('10/02/2023', toJson=True)
if classLevel == '?':
classGrade, classLevel, classGroup, isApprenant = fetchAndParse('10/09/2023', toJson=True)
if classLevel == '?':
classGrade, classLevel, classGroup, isApprenant = fetchAndParse('10/16/2023', toJson=True)
if classLevel == '?':
classGrade, classLevel, classGroup, isApprenant = fetchAndParse('10/23/2023', toJson=True)
if classLevel == '?':
classGrade, classLevel, classGroup, isApprenant = fetchAndParse('10/30/2023', toJson=True)


classe = "%s %s" % (classLevel, classGroup)


Expand Down

0 comments on commit a27b4b4

Please sign in to comment.