Class: NewsmastMastodon::CustomTimelineService
- Inherits:
-
BaseService
- Object
- BaseService
- NewsmastMastodon::CustomTimelineService
- Includes:
- Redisable
- Defined in:
- app/services/newsmast_mastodon/custom_timeline_service.rb
Constant Summary collapse
- MAX_ITEMS =
Maximum number of items stored in a single feed
400
Instance Method Summary collapse
-
#add_custom_public_status(status_id) ⇒ Object
from public status, add to mix_channel_local_timeline.
-
#push_to_mix_channel_local_timeline(status_id) ⇒ Object
Add a status to mix_channel_local_timeline.
-
#remove_custom_public_status(status_id) ⇒ Object
from public status, remove from mix_channel_local_timeline.
-
#timeline_key ⇒ Object
set custom timeline key.
-
#trim ⇒ Object
Trim a feed to maximum size by removing older items.
-
#unpush_from_mix_channel_local_timeline(status_id) ⇒ Object
Remove a status from mix_channel_local_timeline.
Instance Method Details
#add_custom_public_status(status_id) ⇒ Object
from public status, add to mix_channel_local_timeline
23 24 25 26 27 28 |
# File 'app/services/newsmast_mastodon/custom_timeline_service.rb', line 23 def add_custom_public_status(status_id) return unless status_id push_to_mix_channel_local_timeline(status_id) trim end |
#push_to_mix_channel_local_timeline(status_id) ⇒ Object
Add a status to mix_channel_local_timeline
38 39 40 |
# File 'app/services/newsmast_mastodon/custom_timeline_service.rb', line 38 def push_to_mix_channel_local_timeline(status_id) redis.zadd(timeline_key, status_id, status_id) end |
#remove_custom_public_status(status_id) ⇒ Object
from public status, remove from mix_channel_local_timeline
31 32 33 34 35 |
# File 'app/services/newsmast_mastodon/custom_timeline_service.rb', line 31 def remove_custom_public_status(status_id) return unless status_id unpush_from_mix_channel_local_timeline(status_id) end |
#timeline_key ⇒ Object
set custom timeline key
13 14 15 |
# File 'app/services/newsmast_mastodon/custom_timeline_service.rb', line 13 def timeline_key "feed:mix_channel_local_timeline" end |
#trim ⇒ Object
Trim a feed to maximum size by removing older items
18 19 20 |
# File 'app/services/newsmast_mastodon/custom_timeline_service.rb', line 18 def trim redis.zremrangebyrank(timeline_key, 0, -(MAX_ITEMS + 1)) end |
#unpush_from_mix_channel_local_timeline(status_id) ⇒ Object
Remove a status from mix_channel_local_timeline
43 44 45 |
# File 'app/services/newsmast_mastodon/custom_timeline_service.rb', line 43 def unpush_from_mix_channel_local_timeline(status_id) redis.zrem(timeline_key, status_id) end |