Class: Tramway::Bots::Bot
- Inherits:
-
ApplicationRecord
- Object
- Core::ApplicationRecord
- ApplicationRecord
- Tramway::Bots::Bot
- Defined in:
- app/models/tramway/bots/bot.rb
Constant Summary collapse
- TEAMS =
%i[rsm night purple_magic benchkiller].freeze
Instance Method Summary collapse
- #finish_step ⇒ Object
- #finished_users ⇒ Object
- #new_users_between(begin_date, end_date) ⇒ Object
- #start_step ⇒ Object
- #uniq_users_between(begin_date, end_date) ⇒ Object
Instance Method Details
#finish_step ⇒ Object
28 29 30 31 32 |
# File 'app/models/tramway/bots/bot.rb', line 28 def finish_step return unless team.night? scenario_steps.finish_step end |
#finished_users ⇒ Object
34 35 36 37 38 |
# File 'app/models/tramway/bots/bot.rb', line 34 def finished_users return [] unless finish_step.present? progress_records.where(bot_telegram_scenario_step_id: finish_step.id).uniq(&:bot_telegram_user_id) end |
#new_users_between(begin_date, end_date) ⇒ Object
40 41 42 43 44 45 |
# File 'app/models/tramway/bots/bot.rb', line 40 def new_users_between(begin_date, end_date) users.uniq.map do |user| = user..order(created_at: :asc).first.created_at user if .between?(begin_date, end_date) end.compact end |
#start_step ⇒ Object
23 24 25 26 |
# File 'app/models/tramway/bots/bot.rb', line 23 def start_step # scenario_steps.find_by name: :start did not work for some reason. Think it's about step word in Rails scenario_steps.select { |s| s.name == 'start' }.first end |
#uniq_users_between(begin_date, end_date) ⇒ Object
47 48 49 |
# File 'app/models/tramway/bots/bot.rb', line 47 def uniq_users_between(begin_date, end_date) .where('created_at >= ? AND created_at <= ?', begin_date, end_date).map(&:user).uniq end |