Skip to content

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

Open
aajjbb wants to merge 2 commits intoluarocks:masterfrom
aajjbb:email-digest
Open

[WIP] Send an weekly email digest to users#121
aajjbb wants to merge 2 commits intoluarocks:masterfrom
aajjbb:email-digest

Conversation

@aajjbb
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

2 participants