Skip to content

Conversation

@fishilico
Copy link
Member

No description provided.

While at it, "GROUP BY a.uid" to make sure the LEFT JOIN statements did
not introduce multiple lines for each account.
Copy link
Member

@rbarrois rbarrois left a 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'))
Copy link
Member

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ÁÇÉÖàáâãäåçèéêëíîïñóôöúüÿ -]"
Copy link
Member

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?

Copy link
Member Author

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))
Copy link
Member

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('_ecole@alumni.polytechnique.org'):
Copy link
Member

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.

@fishilico
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants