Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

fix(scripts): count from the end when parsing date from file name #71

Merged
merged 1 commit into from
Apr 13, 2017

Conversation

philbooth
Copy link
Contributor

The email events file name in S3 has an extra hyphenated part, which caused import_events.py to include an extra part in the date string. Instead of assuming that everything after the first hyphenated part is a date, we can fix it by counting back three parts from the end.

@vbudhram r?

import_events.py Outdated
@@ -157,7 +157,7 @@ def get_unpopulated_days():
print message
for key in s3.list(prefix=s3_prefix):
filename = path.basename(key.name)
day = "-".join(filename[:-4].split("-")[1:])
day = "-".join(filename[:-4].split("-")[-3:])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can fix it by counting back three parts from the end

It is not 100% obvious to me why go back 3 when only 1 extra hyphen was added?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, thanks. I've added a comment to make this clearer.

@philbooth philbooth merged commit cb7c4ab into master Apr 13, 2017
@philbooth philbooth deleted the phil/robust-date branch April 13, 2017 14:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants