Class: Checkoff::SelectorClasses::Task::LastStoryCreatedLessThanNDaysAgoPFunctionEvaluator

Inherits:
FunctionEvaluator show all
Defined in:
lib/checkoff/internal/selector_classes/task.rb

Overview

:last_story_created_less_than_n_days_ago? function

Constant Summary collapse

FUNCTION_NAME =
:last_story_created_less_than_n_days_ago?

Instance Attribute Summary

Attributes inherited from FunctionEvaluator

#custom_fields, #tasks, #timelines

Instance Method Summary collapse

Methods inherited from FunctionEvaluator

#initialize

Methods included from Logging

#debug, #error, #finer, #info, #logger, #warn

Constructor Details

This class inherits a constructor from Checkoff::SelectorClasses::Task::FunctionEvaluator

Instance Method Details

#evaluate(task, num_days, excluding_resource_subtypes) ⇒ Boolean

Parameters:

  • task (Asana::Resources::Task)
  • num_days (Integer)
  • excluding_resource_subtypes (Array<String>)

Returns:

  • (Boolean)


231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/checkoff/internal/selector_classes/task.rb', line 231

def evaluate(task, num_days, excluding_resource_subtypes)
  # for whatever reason, .last on the enumerable does not impose ordering; .to_a does!

  # @type [Array<Asana::Resources::Story>]
  stories = task.stories(per_page: 100).to_a.reject do |story|
    # @sg-ignore
    excluding_resource_subtypes.include? story.resource_subtype
  end
  return true if stories.empty? # no stories == infinitely old!

  last_story = stories.last
  # @sg-ignore
  last_story_created_at = Time.parse(last_story.created_at)
  n_days_ago = Time.at(Time.now.to_i - (num_days * 86_400))
  last_story_created_at < n_days_ago
end

#evaluate_arg?(_index) ⇒ Boolean

Returns:

  • (Boolean)


223
224
225
# File 'lib/checkoff/internal/selector_classes/task.rb', line 223

def evaluate_arg?(_index)
  false
end

#matches?Boolean

Returns:

  • (Boolean)


219
220
221
# File 'lib/checkoff/internal/selector_classes/task.rb', line 219

def matches?
  fn?(selector, FUNCTION_NAME)
end