-
Notifications
You must be signed in to change notification settings - Fork 193
/
Copy pathpolitical_content_identifier.rb
72 lines (56 loc) · 1.57 KB
/
political_content_identifier.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
class PoliticalContentIdentifier
POTENTIALLY_POLITICAL_FORMATS = [
CallForEvidence,
CaseStudy,
Consultation,
Speech,
NewsArticle,
].freeze
POLITICAL_PUBLICATION_TYPES = [
PublicationType::CorporateReport,
PublicationType::ImpactAssessment,
PublicationType::PolicyPaper,
].freeze
attr_reader :edition
def initialize(edition)
@edition = edition
end
def self.political?(edition)
new(edition).political?
end
def political?
return false if never_political_format?
associated_with_a_minister? ||
always_political_format? ||
(potentially_political_format? && has_political_org?)
end
private
def stats_publication?
edition.is_a?(Publication) && edition.statistics?
end
def associated_with_a_minister?
edition.is_associated_with_a_minister?
end
def has_political_org?
edition.can_be_related_to_organisations? &&
edition.organisations.where(political: true).any?
end
def potentially_political_format?
potentially_political_publication? || POTENTIALLY_POLITICAL_FORMATS.include?(edition.class)
end
def potentially_political_publication?
edition.is_a?(Publication) && political_publication_type?
end
def political_publication_type?
POLITICAL_PUBLICATION_TYPES.include?(edition.publication_type)
end
def always_political_format?
edition_is_a_world_news_story?
end
def never_political_format?
edition.is_a?(FatalityNotice) || stats_publication?
end
def edition_is_a_world_news_story?
edition.is_a?(NewsArticle) && edition.world_news_story?
end
end