[WIP] Send an weekly email digest to users#121
[WIP] Send an weekly email digest to users#121aajjbb wants to merge 2 commits intoluarocks:masterfrom
Conversation
|
The feature of listing the 5 latest timeline events to the digest depends on #117 |
applications/user.moon
Outdated
| 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 |
There was a problem hiding this comment.
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
| -- render: true | ||
|
|
||
| UserDigest = require "emails.user_digest" | ||
| UserDigest\send @, @current_user.email, { |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
I used the endpoint in a controller for testing purposes. I'll create a specific flow to be the mailer.
widgets/weekly_favorite_modules.moon
Outdated
| @@ -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!" | |||
There was a problem hiding this comment.
It looks like this text is duplicated in the email template
This is a WIP Pull Request, aiming to sends an weekly email to LuaRocks users with the latest things that happened in the website.