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 rake task mastodon:feeds:build to regenerate all active users' feeds #4303

Merged
merged 1 commit into from
Jul 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class User < ApplicationRecord
scope :admins, -> { where(admin: true) }
scope :confirmed, -> { where.not(confirmed_at: nil) }
scope :inactive, -> { where(arel_table[:current_sign_in_at].lt(ACTIVE_DURATION.ago)) }
scope :active, -> { confirmed.where(arel_table[:current_sign_in_at].gteq(ACTIVE_DURATION.ago)).joins(:account).where(accounts: { suspended: false }) }
scope :matches_email, ->(value) { where(arel_table[:email].matches("#{value}%")) }
scope :with_recent_ip_address, ->(value) { where(arel_table[:current_sign_in_ip].eq(value).or(arel_table[:last_sign_in_ip].eq(value))) }

Expand Down
7 changes: 7 additions & 0 deletions lib/tasks/mastodon.rake
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ namespace :mastodon do
task clear_all: :environment do
Redis.current.keys('feed:*').each { |key| Redis.current.del(key) }
end

desc 'Generates home timelines for users who logged in in the past two weeks'
task build: :environment do
User.active.includes(:account).find_each do |u|
PrecomputeFeedService.new.call(u.account)
end
end
end

namespace :emails do
Expand Down