Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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('[email protected]'):
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.

2 participants