-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New script to export data for school's newsletter #146
base: master
Are you sure you want to change the base?
Conversation
While at it, "GROUP BY a.uid" to make sure the LEFT JOIN statements did not introduce multiple lines for each account.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add the quick unsubscribe link, based on the hash
column in newsletter_ins
?
https://www.polytechnique.org/epletter/out/<hash>
|
||
# Load platal.conf and connect | ||
conf = configparser.SafeConfigParser() | ||
conf.read(os.path.join(os.path.dirname(__file__), '..', 'platal.conf')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Use os.path.pardir
instead of '..'
# Sanity checks before adding a row, in order to make sure we do not transmit invalid data to the school | ||
firstname, lastname, promo, email = row | ||
|
||
name_charset = r"[^'.a-zA-ZÁÇÉÖàáâãäåçèéêëíîïñóôöúüÿ -]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this set of valid chars?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it is the charset of all the names currently in the database. If you know a reference set of characters that are acceptable in names, it can be changed to it.
|
||
invalid_characters = set(re.findall(r'[^0-9BDEGMX ]', promo.replace('D (en cours)', ''))) | ||
if invalid_characters: | ||
print("Warning: invalid characters in promo %r: %r" % (promo, invalid_characters)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would those be? Shouldn't we crash?
if invalid_characters: | ||
print("Warning: invalid characters in promo %r: %r" % (promo, invalid_characters)) | ||
|
||
if not email.endswith('[email protected]'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should crash here: this case is impossible from the query construction.
For "Shouldn't we crash?", the idea is to report all the issues from the data in order to fix them all, instead of: "run the script until the first error, fix it, run the script again to the next error, fix the other one, etc.". Exiting with an error status should be good enough. |
No description provided.