|
|
|
|
|
3class ArchivePetitionJob < ApplicationJob
|
|
4 queue_as :high_priority
|
|
|
- DuplicateMethodCall - calls 'parliament.petitions' 2 times » reek
- DuplicateMethodCall - calls 'petition.id' 2 times » reek
- FeatureEnvy - refers to 'p' more than self (maybe move it to another class?) » reek
- NestedIterators - contains iterators nested 2 deep » reek
- NestedIterators - contains iterators nested 3 deep » reek
- TooManyStatements - has approx 70 statements » reek
- UncommunicativeVariableName - has the variable name 'c' » reek
- UncommunicativeVariableName - has the variable name 'e' » reek
- UncommunicativeVariableName - has the variable name 'l' » reek
- UncommunicativeVariableName - has the variable name 'n' » reek
- UncommunicativeVariableName - has the variable name 'o' » reek
- UncommunicativeVariableName - has the variable name 'p' » reek
- UncommunicativeVariableName - has the variable name 'r' » reek
- Complexity 19 » saikuro
- Method name "perform" cyclomatic complexity is 11. It should be 8 or less. » roodi
|
|
|
7 unless petition.archived? || parliament.petitions.exists?(petition.id)
|
- Block cyclomatic complexity is 9. It should be 4 or less. » roodi
|
8 archived_petition = parliament.petitions.create! do |p|
|
|
|
|
10 p.action = petition.action
|
|
11 p.background = petition.background
|
|
12 p.additional_details = petition.additional_details
|
|
13 p.state = petition.state
|
|
14 p.debate_state = petition.debate_state
|
|
15 p.special_consideration = petition.special_consideration
|
|
16 p.opened_at = petition.opened_at
|
|
17 p.closed_at = petition.closed_at
|
|
18 p.rejected_at = petition.rejected_at
|
|
19 p.stopped_at = petition.stopped_at
|
|
20 p.signature_count = petition.signature_count
|
|
21 p.moderation_threshold_reached_at = petition.moderation_threshold_reached_at
|
|
22 p.moderation_lag = petition.moderation_lag
|
|
23 p.last_signed_at = petition.last_signed_at
|
|
24 p.response_threshold_reached_at = petition.response_threshold_reached_at
|
|
25 p.government_response_at = petition.government_response_at
|
|
26 p.debate_threshold_reached_at = petition.debate_threshold_reached_at
|
|
27 p.scheduled_debate_date = petition.scheduled_debate_date
|
|
28 p.debate_outcome_at = petition.debate_outcome_at
|
|
29 p.created_at = petition.created_at
|
|
30 p.updated_at = petition.updated_at
|
|
|
- Found = in conditional. It should probably be an == » roodi
|
32 if receipt = petition.email_requested_receipt
|
|
33 p.email_requested_for_government_response_at = receipt.government_response
|
|
34 p.email_requested_for_debate_scheduled_at = receipt.debate_scheduled
|
|
35 p.email_requested_for_debate_outcome_at = receipt.debate_outcome
|
|
36 p.email_requested_for_petition_email_at = receipt.petition_email
|
|
|
|
|
- Found = in conditional. It should probably be an == » roodi
|
39 if note = petition.note
|
|
|
|
41 n.details = note.details
|
|
42 n.created_at = note.created_at
|
|
43 n.updated_at = note.updated_at
|
|
|
|
|
|
|
- Found = in conditional. It should probably be an == » roodi
|
47 if rejection = petition.rejection
|
|
48 p.build_rejection do |r|
|
|
49 r.code = rejection.code
|
|
50 r.details = rejection.details
|
|
51 r.created_at = rejection.created_at
|
|
52 r.updated_at = rejection.updated_at
|
|
|
|
|
|
|
|
56 petition.emails.each do |email|
|
|
|
|
58 e.subject = email.subject
|
|
|
|
60 e.sent_by = email.sent_by
|
|
61 e.created_at = email.created_at
|
|
62 e.updated_at = email.updated_at
|
|
|
|
|
|
|
- Found = in conditional. It should probably be an == » roodi
|
66 if government_response = petition.government_response
|
|
67 p.build_government_response do |r|
|
|
68 r.responded_on = government_response.responded_on
|
|
69 r.summary = government_response.summary
|
|
70 r.details = government_response.details
|
|
71 r.created_at = government_response.created_at
|
|
72 r.updated_at = government_response.updated_at
|
|
|
|
|
|
|
- Found = in conditional. It should probably be an == » roodi
|
76 if debate_outcome = petition.debate_outcome
|
|
77 p.build_debate_outcome do |o|
|
|
78 o.debated = debate_outcome.debated
|
|
79 o.debated_on = debate_outcome.debated_on
|
|
80 o.transcript_url = debate_outcome.transcript_url
|
|
81 o.video_url = debate_outcome.video_url
|
|
82 o.debate_pack_url = debate_outcome.debate_pack_url
|
|
83 o.overview = debate_outcome.overview
|
|
84 o.created_at = debate_outcome.created_at
|
|
85 o.updated_at = debate_outcome.updated_at
|
|
|
|
87 if debate_outcome.commons_image?
|
|
88 tempfile = Tempfile.new("commons_image")
|
|
89 debate_outcome.commons_image.copy_to_local_file(:original, tempfile.path)
|
|
|
|
|
|
92 o.commons_image = tempfile
|
|
93 o.commons_image_file_name = debate_outcome.commons_image_file_name
|
|
|
|
|
|
|
|
|
|
98 constituencies = petition.signatures_by_constituency
|
|
99 unless constituencies.empty?
|
|
100 p.signatures_by_constituency = Hash[constituencies.map { |c| [c.constituency_id, c.signature_count] }]
|
|
|
|
|
|
103 locations = petition.signatures_by_country
|
|
104 unless locations.empty?
|
|
105 p.signatures_by_country = Hash[locations.map { |l| [l.location_code, l.signature_count] }]
|
|
|
|
|
|
|
|
109 ArchiveSignaturesJob.perform_later(petition, archived_petition)
|
|
|
|
|
|
|
|
|
|
|
- UtilityFunction - doesn't depend on instance state (maybe move it to another class?) » reek
- Complexity 1 » saikuro
|
|
|
|
|
|
|
|