Compare commits

...

4 Commits

Author SHA1 Message Date
79678a8920 upcomingEvents: Use cleaner datetime format 2023-09-22 22:13:03 -04:00
8b845bab05 Apply black formatting 2023-09-22 22:13:03 -04:00
ef23433c8f sqlExport: Remove debug print 2023-09-22 22:13:03 -04:00
936effe5c7 sqlExport: Just insert transactions, instead of trying to upsert
This fixes an issue that seems to have only manifested on newer Python
versions (maybe >3.9, after update to Debian 12)
2023-09-22 22:12:08 -04:00
3 changed files with 20 additions and 7 deletions

View File

@ -101,7 +101,7 @@ def main():
"charset": "utf8",
"sql_mode": "PIPES_AS_CONCAT",
"use_unicode": True,
}
},
)
HIDEvent.create_table()
for door in config.doors.values():

View File

@ -45,9 +45,6 @@ def do_import(config):
# create/update member
Member.from_csv_dict(member).magic_save()
if member["Account Name"] == "Adam Goldsmith":
print(member)
# update member's flags
for type, flags in membershipworks._parse_flags().items():
for flag, id in flags.items():
@ -76,7 +73,7 @@ def do_import(config):
)
for transaction in transactions:
Transaction.from_csv_dict(transaction).magic_save()
Transaction.from_csv_dict(transaction).insert_instance().execute()
# TODO: folders, levels, addons
@ -89,7 +86,7 @@ def main():
"charset": "utf8",
"sql_mode": "PIPES_AS_CONCAT",
"use_unicode": True,
}
},
)
do_import(config)

View File

@ -7,6 +7,22 @@ import pyclip
from .config import Config
TIME_FMT = "%l:%M%P"
DATETIME_FMT = "%a %b %e %Y, " + TIME_FMT
def format_datetime_range(start_ts: int, end_ts: int):
start = datetime.fromtimestamp(start_ts)
end = datetime.fromtimestamp(end_ts)
start_str = start.strftime(DATETIME_FMT)
if start.date() == end.date():
end_str = end.strftime(TIME_FMT)
else:
# TODO: this probably implies multiple instances. Should read
# RRULE or similar from the event notes
end_str = end.strftime(DATETIME_FMT)
return f"{start_str} — {end_str}"
def format_event(event_details, truncate: bool):
try:
@ -22,7 +38,7 @@ def format_event(event_details, truncate: bool):
out = f"""<h2 style="text-align: center;">
<a href="{url}">{img}{event_details['ttl']}</a>
</h2>
<div><i>{event_details['szp']} &mdash; {event_details['ezp']}</i></div>
<div><i>{format_datetime_range(event_details['sdp'], event_details['edp'])}</i></div>
"""
if not truncate:
out += f"""