Skip to content

Commit

Permalink
bulk channels
Browse files Browse the repository at this point in the history
  • Loading branch information
jtomchak committed Dec 22, 2023
1 parent 8e58e2d commit 23e208a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/lib/mammoth/channels.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def select_channels_with_statuses(channels, user)
origin = Mammoth::StatusOrigin.instance
channel_feed_manager = ChannelFeedManager.instance
channels.flat_map do |channel|
channel_feed_manager.fetch_threshold_statuses(channel[:id]).each { |s| origin.add_channel(s, user, channel) }
origin.bulk_add_channel(channel_feed_manager.fetch_threshold_statuses(channel[:id]), user, channel)
end
end

Expand Down
10 changes: 10 additions & 0 deletions app/lib/mammoth/status_origin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ def add_channel(status, user, channel)

add_reason(list_key, status[:id], reason)
end

def bulk_add_channel(statuses, user, channel)
reasons = statuses.map do |s|
list_key = key(user[:acct], s[:id])
reason = channel_reason(s, channel)
return {key: list_key, id: s[:id], reason: reason}
end
bulk_reasons(reasons)
end

# Add MammothPick and Reason to list
def add_mammoth_pick(status, user)
Expand All @@ -50,6 +59,7 @@ def bulk_add_mammoth_pick(statuses, user)
reason = mammoth_pick_reason(s)
return {key: list_key, id: s[:id], reason: reason}
end
bulk_reasons(reasons)
end

def bulk_reasons(reasons)
Expand Down

0 comments on commit 23e208a

Please sign in to comment.