|
1module ArchivedPetitionHelper
|
- UtilityFunction - doesn't depend on instance state (maybe move it to another class?) » reek
- Complexity 2 » saikuro
|
2 def archived_threshold(petition)
|
|
3 if petition.threshold_for_response_reached? || petition.government_response?
|
|
4 petition.threshold_for_debate
|
|
|
|
6 petition.threshold_for_response
|
|
|
|
|
|
|
|
10 def archived_threshold_percentage(petition)
|
|
11 threshold = archived_threshold(petition)
|
|
12 percentage = Rational(petition.signature_count, threshold) * 100
|
|
13 percentage = [[1, percentage].max, 100].min
|
|
|
|
15 number_to_percentage(percentage, precision: 2)
|
|
|
|
|
|
18 def archived_parliaments
|
|
19 @archived_parliaments ||= Parliament.archived
|
|
|
|
|
|
22 def archived_petition_facets_with_counts(petitions)
|
|
23 petitions.facets.slice(*archived_petition_facets)
|
|
|
|
|
- DuplicateMethodCall - calls 'duration.floor' 3 times » reek
- DuplicateMethodCall - calls 'duration.frac' 3 times » reek
- DuplicateMethodCall - calls 'pluralize(duration.floor, "month")' 3 times » reek
- FeatureEnvy - refers to 'duration' more than self (maybe move it to another class?) » reek
- Complexity 4 » saikuro
|
26 def petition_duration_to_words(duration)
|
|
27 duration = duration.to_d
|
|
|
|
29 if duration.frac.zero?
|
|
30 pluralize(duration.floor, "month")
|
|
31 elsif duration.frac > 0.75
|
|
32 "nearly #{pluralize(duration.ceil, "month")}"
|
|
33 elsif duration.frac < 0.25
|
|
34 "just over #{pluralize(duration.floor, "month")}"
|
|
|
|
36 "over #{pluralize(duration.floor, "month")}"
|
|
|
|
|
|
|