checkoff 0.52.0 → 0.53.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/checkoff/internal/task_selector_evaluator.rb +42 -0
- data/lib/checkoff/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70e5f767656e34b2431a2920a57ade34d64480f53d95855818bd607400ae9e60
|
4
|
+
data.tar.gz: 42b5dc27c71e1f0bb5772f00d8ae74947286f13e7bb319d9ae8ab2c8dbb06722
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8327942085367d3501b77563121dab0935696550a46036da89f4662d59d5dd7acc9fa49930db08f3901a1468b05c5ab63a2f813ab56415c9f627887b585d8386
|
7
|
+
data.tar.gz: 6046d32bfd28b7805771be9854843821d0d84c2da3e49eac3df3f44d839169b073117870a38e67659e4f3ca0356151bcbfc4eb2feabbb7a6ffc88efe7917673b
|
data/Gemfile.lock
CHANGED
@@ -497,6 +497,47 @@ module Checkoff
|
|
497
497
|
task_selector
|
498
498
|
end
|
499
499
|
end
|
500
|
+
|
501
|
+
# :estimate_exceeds_duration
|
502
|
+
class EstimateExceedsDurationFunctionEvaluator < FunctionEvaluator
|
503
|
+
FUNCTION_NAME = :estimate_exceeds_duration
|
504
|
+
|
505
|
+
def matches?
|
506
|
+
fn?(task_selector, FUNCTION_NAME)
|
507
|
+
end
|
508
|
+
|
509
|
+
# @param task [Asana::Resources::Task]
|
510
|
+
# @return [Float]
|
511
|
+
def calculate_allocated_hours(task)
|
512
|
+
due_on = nil
|
513
|
+
start_on = nil
|
514
|
+
start_on = Date.parse(task.start_on) unless task.start_on.nil?
|
515
|
+
due_on = Date.parse(task.due_on) unless task.due_on.nil?
|
516
|
+
allocated_hours = 8.0
|
517
|
+
# @sg-ignore
|
518
|
+
allocated_hours = (due_on - start_on + 1).to_i * 8.0 if start_on && due_on
|
519
|
+
allocated_hours
|
520
|
+
end
|
521
|
+
|
522
|
+
# @param task [Asana::Resources::Task]
|
523
|
+
# @return [Boolean]
|
524
|
+
def evaluate(task)
|
525
|
+
custom_field = pull_custom_field_by_name_or_raise(task, 'Estimated time')
|
526
|
+
|
527
|
+
# @sg-ignore
|
528
|
+
# @type [Integer, nil]
|
529
|
+
estimate_minutes = custom_field.fetch('number_value')
|
530
|
+
|
531
|
+
# no estimate set
|
532
|
+
return false if estimate_minutes.nil?
|
533
|
+
|
534
|
+
estimate_hours = estimate_minutes / 60.0
|
535
|
+
|
536
|
+
allocated_hours = calculate_allocated_hours(task)
|
537
|
+
|
538
|
+
estimate_hours > allocated_hours
|
539
|
+
end
|
540
|
+
end
|
500
541
|
end
|
501
542
|
|
502
543
|
# Evaluator task selectors against a task
|
@@ -527,6 +568,7 @@ module Checkoff
|
|
527
568
|
Checkoff::TaskSelectorClasses::CustomFieldLessThanNDaysFromNowFunctionEvaluator,
|
528
569
|
Checkoff::TaskSelectorClasses::CustomFieldGreaterThanOrEqualToNDaysFromNowFunctionEvaluator,
|
529
570
|
Checkoff::TaskSelectorClasses::StringLiteralEvaluator,
|
571
|
+
Checkoff::TaskSelectorClasses::EstimateExceedsDurationFunctionEvaluator,
|
530
572
|
].freeze
|
531
573
|
|
532
574
|
# @param task_selector [Array]
|
data/lib/checkoff/version.rb
CHANGED