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

digest email initial functionality #2711

Merged
merged 17 commits into from
Jun 3, 2018

Conversation

ViditChitkara
Copy link
Member

@ViditChitkara ViditChitkara commented May 10, 2018

closes #2694
part of #2104
A test digest button will be given in the user profile, only the user's with tag 'digest-weekly' would be getting the mails. (All the digest-weekly users will get the mails at once).

@PublicLabBot
Copy link

PublicLabBot commented May 10, 2018

1 Message
📖 @ViditChitkara Thank you for your pull request! I’m here to help with some tips and recommendations. Please take a look at the list provided and help us review and accept your contribution! And don’t be discouraged if you see errors – we’re here to help.

Generated by 🚫 Danger

@namangupta01
Copy link
Member

@ViditChitkara Which part of #2104 are you working?

@ViditChitkara
Copy link
Member Author

@jywarren as discussed, I added a simple list of subscribed content to the email content. It would be great, if you could review the code.

Copy link
Member

@jywarren jywarren left a comment

Choose a reason for hiding this comment

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

This looks great. Let's try merging it when it's ready (just ping me!) and then we can subscribe ourselves to see how it works!

class DigestMailJob < ActiveJob::Base
queue_as :default

def perform(*args)
Copy link
Member

Choose a reason for hiding this comment

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

This looks cool but could you add an inline comment explaining a little more about what it does? Thanks!!

@@ -377,6 +377,11 @@ def social_link(site)
nil
end

def send_digest_email
top_picks = self.content_followed_in_period(Time.now - 1.week, Time.now)
Copy link
Member

Choose a reason for hiding this comment

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

Ooh cool! @StlMaris123 check out this being used!!!

@jywarren
Copy link
Member

Can you also share a screenshot of what it looks like now, in this PR? Thank you very much!!!

@jywarren
Copy link
Member

Are there any CodeClimate recommendations you'd like to adjust as well?

👍 👍 👍

@ViditChitkara
Copy link
Member Author

Are there any CodeClimate recommendations you'd like to adjust as well?

Sure I'll do!!

@ViditChitkara
Copy link
Member Author

This looks great. Let's try merging it when it's ready (just ping me!) and then we can subscribe ourselves to see how it works!

For testing this out, we would require resque gem for asynchronous testing. However, if no. of users are limited we could create a rake task and test it out on test servers or something. Creating another pr for resque integration.

@ViditChitkara
Copy link
Member Author

ss-500
Here is a screenshot for a simple list of subscribed content (currently let's show just title). Once the functionality would work properly, we could work on the design.

@ViditChitkara
Copy link
Member Author

ViditChitkara commented May 21, 2018

I hope this looks good to be merged. What do you say?

@ViditChitkara
Copy link
Member Author

Working on #2738 for adding resque as queuing backend.

@jywarren
Copy link
Member

jywarren commented May 22, 2018 via email

@ViditChitkara
Copy link
Member Author

ViditChitkara commented May 22, 2018 via email

@ViditChitkara
Copy link
Member Author

ViditChitkara commented May 26, 2018

@jywarren should I add resque changes here or should we merge them separately?? We can do it either ways and also, should we switch to sidekiq?

@icarito
Copy link
Member

icarito commented May 27, 2018

Hi, we need the Redis service for this to work. Fortunately this can be setup directly from the docker-compose.yml file. I gave instructions on #2738

@ViditChitkara
Copy link
Member Author

travis is running fine here!!

Copy link
Member

@jywarren jywarren left a comment

Choose a reason for hiding this comment

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

Let's add a test here before merging please? Even something simple.

What will trigger the digest sending? At this point it'll be if you have the right user tag right? Can you annotate in this PR description what exact user tag is needed to test it? Thanks!!!

Gemfile.lock Outdated
@@ -218,7 +218,6 @@ GEM
mini_portile2 (~> 2.3.0)
nokogumbo (1.5.0)
nokogiri
oauth (0.5.4)
Copy link
Member

Choose a reason for hiding this comment

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

Hmm I think this needs to be reversed to not affect oath work?

Copy link
Member Author

Choose a reason for hiding this comment

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

Woah!! Don't know where it came from!! I'll remove gemfile.lock related changes.

Copy link
Member Author

Choose a reason for hiding this comment

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

For triggering, can we give a button or something which would be visible only to admins and moderators?

@ViditChitkara
Copy link
Member Author

adding tests!!

@ViditChitkara
Copy link
Member Author

@jywarren written the tests and added a button to profile page for testing out.

@jywarren
Copy link
Member

jywarren commented Jun 2, 2018 via email

@ViditChitkara
Copy link
Member Author

Yes

@jywarren
Copy link
Member

jywarren commented Jun 2, 2018

Oh weird. Can you check the tests and see if you can correct them?

Dangerfile Outdated
@@ -61,5 +61,4 @@ begin

rescue => ex
fail "There was an error with Danger bot's Junit parsing: #{ex.message}"
puts ex.inspect # view the entire error output in the log
end
Copy link
Member

Choose a reason for hiding this comment

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

It didn't like that line? I had that in there so we can read anything that goes wrong ... Is there another way to be able to read the output?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, it says that puts statement should not be included in dangerfile.
Even, that doesn't solve the problem. Now it says:-
Your Dangerfile has had smart quotes sanitised. To avoid issues in the future, you should not use TextEdit for editing it. If you are not using TextEdit, you should turn off smart quotes in your editor of choice.

Copy link
Member Author

Choose a reason for hiding this comment

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

Should we ignore this error for now and let's put the puts line back??

@jywarren
Copy link
Member

jywarren commented Jun 2, 2018 via email

@ViditChitkara
Copy link
Member Author

hi @ViditChitkara, actually line in red was appearing in previous builds too. But , those builds passed after @jywarren updated the token. This time build failed due to this

yep!! Let's see how to fix this!!

@grvsachdeva
Copy link
Member

It seems its due to the Plotsbot trying to print the message. see this https://api.github.com/repos/publiclab/plots2/issues/comments/388153818 .

@jywarren
Copy link
Member

jywarren commented Jun 3, 2018

OH, hm. That's weird, it's the same old octokit error. I had re-assigned the token to Plotsbot user but maybe that user needs admin rights to the repo. I'll check.

/home/travis/.rvm/gems/ruby-2.4.1/gems/octokit-4.9.0/lib/octokit/response/raise_error.rb:16:in `on_complete': PATCH https://api.github.com/repos/publiclab/plots2/issues/comments/388153818: 403 - Must have admin rights to Repository. // See: https://developer.github.com/v3/issues/comments/#edit-a-comment (Octokit::Forbidden)

@jywarren
Copy link
Member

jywarren commented Jun 3, 2018

OK - i made plotsbot a repo admin so it can edit comments!

@jywarren
Copy link
Member

jywarren commented Jun 3, 2018

er, @PublicLabBot

@jywarren
Copy link
Member

jywarren commented Jun 3, 2018

Also, if there are any changes you want to incorporate from CodeClimate suggestions, go for it, otherwise we can just "approve" that. Thanks!

@ViditChitkara
Copy link
Member Author

Followed code-climate suggestions and cool travis works again!!
I guess it's ready now!
Thanks @jywarren

@jywarren jywarren merged commit a2b69d4 into publiclab:master Jun 3, 2018
@ghost ghost removed the ready label Jun 3, 2018
@jywarren
Copy link
Member

jywarren commented Jun 3, 2018

Great work @ViditChitkara !!!!! Thanks everyone for pitching in 🤝 🙌

@ViditChitkara
Copy link
Member Author

Great work @ViditChitkara !!!!! Thanks everyone for pitching in handshake raised_hands

Thanks a lot, everyone for helping out on this!! 😄 👍

@jywarren
Copy link
Member

jywarren commented Jun 6, 2018

Testing this now!

Hm, I got a 500 error --

There was an error. Are you sure you have the right address?

I wonder what happened? We can check the logs.

@jywarren
Copy link
Member

jywarren commented Jun 6, 2018

I also added my own profile tag of digest:weekly

https://publiclab.org/profile/warren

@jywarren
Copy link
Member

jywarren commented Jun 6, 2018

OK -- error is:

Started GET "/users/test_digest_email" for 172.56.22.214 at 2018-06-06 22:12:08 +0000
Processing by UsersController#test_digest_email as HTML
Completed 500 Internal Server Error in 7ms (ActiveRecord: 1.2ms)
  
Redis::CannotConnectError (Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED)):
  app/controllers/users_controller.rb:301:in `test_digest_email'

If you'd like to open an issue to track and solve this, please do!

@icarito
Copy link
Member

icarito commented Jun 7, 2018

Yeah, my reading of this is that according to

sidekiq_config = { url: ENV['JOB_WORKER_URL'] }
we need an environment variable to direct the app to the proper Redis service. By default it looks for 127.0.0.1 (localhost) but in this case it is in a separate container with hostname redis. So the URL should be in the JOB_WORKER_URL environment variable and it should be something like redis://redis

@icarito
Copy link
Member

icarito commented Jun 7, 2018

I'm thinking now that we are configuring the application with environment variables we should have a good practice of naming these env variables because we could have some confusion. So the appropriate name for this environment variable would be REDIS_URL, I think. Thanks for working on this! 😃

SrinandanPai pushed a commit to SrinandanPai/plots2 that referenced this pull request May 5, 2019
* digest email initial functionality

* minor changes

* changes in digest email design

* added job for digest mailer

* codeclimate fixes

* minor change

* minor change

* minor change

* minor change

* minor change

* removed gemfile.lock related changes

* written tests

* removed puts from dangerfile

* minor changes

* code-climate fixes

* more code-climate fixes

* minor changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UI, design and testing for publiclab digest feature
6 participants