model.rb 781 B

123456789101112131415161718192021222324252627282930313233
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Service::Translation::Search::Collector::Model < Service::Translation::Search::Collector
  3. def self.type
  4. :translation
  5. end
  6. def list
  7. Translation.not_customized.where(locale: locale).limit(limit).details
  8. end
  9. def search
  10. search_by_query.limit(limit).details
  11. end
  12. def count
  13. if mode == :list
  14. return Translation.not_customized.where(locale: locale).count
  15. end
  16. search_by_query.count
  17. end
  18. private
  19. def search_by_query
  20. Translation.not_customized.where(
  21. "locale = :locale AND (source #{like_operator} :query OR target #{like_operator} :query OR target_initial #{like_operator} :query)",
  22. locale: locale,
  23. query: like_query
  24. )
  25. end
  26. end