Fixes #1 Adding event organizer to the /trackdays blurb and also fixing it so if an org only has one day, it will still show up

This commit is contained in:
Luke Robles 2023-10-15 17:50:05 -07:00
parent 2d9e87df68
commit 768c6d12fd
2 changed files with 15 additions and 4 deletions

View File

@ -132,7 +132,12 @@ class ActualUtils(commands.Cog):
)
for track_day in events:
embed.add_field(
name="-------------\n**Event Name**",
name="-------------\n**Organizer**",
value=track_day["event_organizer"],
inline=False,
)
embed.add_field(
name="**Event Name**",
value=track_day["event_name"],
inline=False,
)

View File

@ -13,7 +13,6 @@ async def get_msreg(track):
"turn8": "F3469266-BEFF-E329-4FD6C4B189ACE2A8",
"speedventures": "DF7453ED-BF33-DC17-2C9BFD84C1F05E86",
"nextlevel": "CC23AEA4-AAB1-D087-4A10818D229DAFD2",
"corsaclub": "CE6E69CF-BAEC-DBB6-303EE7D3EC69B8A3",
"lightspeed": "BC6417B8-0ED9-DD48-28BA1463C2C14322",
"socaldriversclub": "B4FC0113-C903-E9D3-68562D6765806945",
}
@ -35,10 +34,16 @@ async def get_msreg(track):
json.dumps(xmltodict.parse(awaited_xml_blob)["response"]["events"])
)
# If an organizer only has one upcoming event on MSReg, it is a dict, otherwise its a list of dicts
# My code assumes list of dicts, so wrap the event dict in a list of 1 item
if json_blob and isinstance(json_blob["event"], dict):
json_blob["event"] = [json_blob["event"]]
try:
for event in json_blob["event"]:
if any(x in event["name"].lower() for x in tracks_we_care_about):
event_object = {
"event_organizer": event["organization"]["name"],
"event_name": event["name"],
"event_url": event["detailuri"].split("?utm")[0],
"event_date": event["start"],
@ -55,7 +60,9 @@ async def get_msreg(track):
),
)
except TypeError:
except Exception as e:
print("Errored on %s" % org_name)
print(e)
pass
return events
@ -68,7 +75,6 @@ def get_corsa_club():
for event in products_blob:
# Filter out hoodies and what not, only care about track days that list run-groups as the options
if any("Intermediate" in s for s in event["options"][0]["values"]):
# pp.pprint(event)
event_object = {
"event_name": event["title"],
"event_url": base_url + "/products/" + event["handle"],