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

[WIP] Send an weekly email digest to users #121

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

Conversation

aajjbb
Copy link
Collaborator

@aajjbb aajjbb commented Aug 21, 2017

This is a WIP Pull Request, aiming to sends an weekly email to LuaRocks users with the latest things that happened in the website.

@aajjbb
Copy link
Collaborator Author

aajjbb commented Aug 22, 2017

The feature of listing the 5 latest timeline events to the digest depends on #117

import Modules from require "models"

weekly_favorites_followings_query = db.query "select object_id, count(*) from followings
where object_type = 1 and created_at >= current_date - interval \'7\' day
Copy link
Collaborator

Choose a reason for hiding this comment

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

the backslashes aren't necessary. If you don't need interplation (which you should generally avoid for queries), then I recommend using Lua's ``[[ and ]]` string delimiters

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

-- render: true

UserDigest = require "emails.user_digest"
UserDigest\send @, @current_user.email, {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's probably worth having a record of when the digest email is sent. Maybe a new model.

Additionally, it's probably not going to be sent by someone visiting a URL, so maybe the code to send the digest could be a method on the users model, or a separate flow.

(I'll add a cron job to send this out automatically later)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I used the endpoint in a controller for testing purposes. I'll create a specific flow to be the mailer.

@@ -0,0 +1,7 @@
class WeeklyFavoriteModules extends require "widgets.page"
inner_content: =>
h2 "Hello #{@current_user\name_for_display!}, here is your weekly digest from LuaRocks, enjoy!"
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like this text is duplicated in the email template

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

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.

None yet

2 participants