The code powering m.abunchtell.com https://m.abunchtell.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

22 lines
592 B

  1. # frozen_string_literal: true
  2. class ProcessHashtagsService < BaseService
  3. def call(status, tags = [])
  4. tags = Extractor.extract_hashtags(status.text) if status.local?
  5. records = []
  6. Tag.find_or_create_by_names(tags) do |tag|
  7. status.tags << tag
  8. records << tag
  9. TrendingTags.record_use!(tag, status.account, status.created_at) if status.public_visibility?
  10. end
  11. return unless status.distributable?
  12. status.account.featured_tags.where(tag_id: records.map(&:id)).each do |featured_tag|
  13. featured_tag.increment(status.created_at)
  14. end
  15. end
  16. end