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

Add an app to update the email signature PNG daily. #122

Merged
merged 3 commits into from
Jun 5, 2018

Conversation

YPCrumble
Copy link
Contributor

@lwm in the spirit of moving quickly, this is a preliminary PR for adding the email signature png.

The path should be:

https://api.carbondoomsday.com/media/carbondoomsday_email_signature.png

I wrote a couple tests for the Python portion of the implementation, but I'm less confident about my celery and dokku integrations...and not sure how to build out the staging server so they're untested. Would love any feedback and happy to make adjustments as required. Thanks!

@decentral1se
Copy link
Member

decentral1se commented May 18, 2018

I'll get to a proper review on this later today or tomorrow!

Thanks for coming back to this :)

EDIT: CI seems to be complaining about missing a pipenv lock or whatever.

'carbondoomsday.email_signature.tasks.'
'update_email_signature'
),
'schedule': timedelta(days=1)
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps this should be fired manually from the other celery tasks. For example, if the latest data updates at some strange time and this runs before that, the signature will not have the latest data. I think you'll want to try with apply_async.

# https://stackoverflow.com/a/273962/2532070
# https://stackoverflow.com/a/2563883/2532070
# add_border_radius method:
# https://stackoverflow.com/a/11291419/2532070
Copy link
Member

Choose a reason for hiding this comment

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

If these are useful to help understand the following code then I'd rather see them closer to the code that is using something from them. That might be in a function docstring in the usual """ my docstring """? If more general, could also use the module docstring at the top here.

@decentral1se
Copy link
Member

decentral1se commented May 19, 2018

Looks good! Nice one! Although I do question whether we need to the separate app for it? I imagined it being included in the original carbondoomsday app.

I'm going to submit a PR (see #123) to clear up our current CI pipenv issues. That might give you some conflict issues which you'll need to rebase over and resolve but you'll get a clean CI run then!

@YPCrumble
Copy link
Contributor Author

@lwm do you mean to day the "measurements" app? I didn't think the signature was really a measurement so put it in a new app. Happy to move it to the measurements app if you prefer. I usually try to make apps do one thing only and most of my apps are quite simple, but I really don't know if that's a good practice or not!

@decentral1se
Copy link
Member

usually try to make apps do one thing only

I approve of your zealous UNIX attitude! Let's do it.

@decentral1se
Copy link
Member

The CI failures probably needs a similar to #121 (comment) treatment?

from carbondoomsday.measurements.models import CO2


# ppm = "412.32"
Copy link
Member

Choose a reason for hiding this comment

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

We can remove this?

@decentral1se
Copy link
Member

OK, let's get this PR going green and I will try to do some background work to get you able to make deployments and such. Then we deploy and therefore win.

@YPCrumble YPCrumble force-pushed the add_email_signature branch 2 times, most recently from a0093e1 to 49fecf3 Compare May 29, 2018 15:31
@YPCrumble
Copy link
Contributor Author

YPCrumble commented May 29, 2018

@lwm I think I'm getting closer - the isort functionality is still confusing me.

This is the result from TravisCI: https://cl.ly/0e0y3K3I142M

This is the result when I run make sort on my machine after making the change suggested by TravisCI: https://cl.ly/0z1W1N1d2v1f

@YPCrumble
Copy link
Contributor Author

@lwm nevermind - this is related to the fact that PIL is actually Pillow and making isort fritz out. Adding it to known_third_party in setup.cfg should fix; relaunching TravisCI now.

@codecov-io
Copy link

codecov-io commented May 29, 2018

Codecov Report

Merging #122 into master will increase coverage by 0.61%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #122      +/-   ##
==========================================
+ Coverage      97%   97.61%   +0.61%     
==========================================
  Files          25       27       +2     
  Lines         534      546      +12     
==========================================
+ Hits          518      533      +15     
+ Misses         16       13       -3
Impacted Files Coverage Δ
carbondoomsday/email_signature/tasks.py 100% <100%> (ø)
carbondoomsday/email_signature/utils.py 100% <100%> (ø)
...msday/email_signature/test/test_email_signature.py 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1c0e6f8...55b19c0. Read the comment docs.

@YPCrumble
Copy link
Contributor Author

@lwm I'm getting closer! You run a tight ship here. Codecov is complaining because my settings.py file isn't fully tested. My suggestion is we either reduce the coverage % or exclude settings.py from coverage - does one or the other (or something else) work for you?

@decentral1se
Copy link
Member

Nice one!

You run a tight ship here.

😆

TBH, I'm easy with whatever you can configure. The changes looks good to me, from another brief look. Can you send me your SSH public key part? I'll get you access to the machines.

@YPCrumble YPCrumble force-pushed the add_email_signature branch 2 times, most recently from 7c6e9c7 to 04b66df Compare June 4, 2018 15:03
Remove unnecessary comment.

Use isort to update import order.

Add PIL to known_third_party settings.

Update pipfile.lock.
@YPCrumble
Copy link
Contributor Author

YPCrumble commented Jun 5, 2018

Ahhhhh I'm green!

If this now looks good, would you pull in and I can:

  1. Check to confirm that the image is getting created and served appropriately
  2. Add the email signature to the frontend site!

What's your email to send the public key to @lwm ?

@decentral1se
Copy link
Member

Send it over to lukewm AT riseup.net (here's my key if you're into that stuff). I'm going to merge this because I want to get off Github tonight (if possible). I'll add an issue on the migrated repository with those 1. and 2. points!

Thanks for this work! Solid stuff 🔥 🔥 🔥

@decentral1se decentral1se merged commit 9bd69b8 into master Jun 5, 2018
@decentral1se
Copy link
Member

🚀

@decentral1se decentral1se deleted the add_email_signature branch June 5, 2018 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants