Skip to content

Commit 8d49c30

Browse files
authored
Merge pull request #739 from guardian/pf/add-paapi-plus-definition
Exclude legacy PA feeds when 'showPAAPI' is true
2 parents 97288fb + 1efc4b4 commit 8d49c30

File tree

2 files changed

+57
-8
lines changed

2 files changed

+57
-8
lines changed

newswires/app/models/SearchParams.scala

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,40 @@ object SearchParams {
8585
dotCopyExclusion ::: guSuppliersExclusion ::: exclusionFromParams
8686
}
8787

88+
val legacyPaSourceFeeds = List(
89+
"PA PR NEWSWIRE",
90+
"PA PA MEDIA PRESS CENTRES",
91+
"PA PA MEDIA ASSIGNMENTS",
92+
"PA BUSINESSWIRE",
93+
"PA THE ACADEMY OF MEDICAL SCIENCES",
94+
"PA PA SPORT LATEST",
95+
"PA PRESSWIRE",
96+
"PA PA",
97+
"PA GLOBENEWSWIRE",
98+
"PA EQS NEWSWIRE",
99+
"PA LATEST",
100+
"PA RESPONSESOURCE",
101+
"PA ACCESS NEWSWIRE",
102+
"PA UK GOVERNMENT AND PUBLIC SECTOR",
103+
"PA PA SPORT",
104+
"PA PA ADVISORY",
105+
"PA AGILITY PR SOLUTIONS",
106+
"PA NEWS AKTUELL",
107+
"PA ADVISORY",
108+
"PA MARKETTIERS",
109+
"PA RNS",
110+
"PA",
111+
"PA PA SPORT SNAP",
112+
"PA NEWSFILE",
113+
"PA PRESSAT",
114+
"PA SNAP"
115+
)
116+
117+
val newPaSourceFeeds = List(
118+
"PA_API",
119+
"PA_API DATA FORMATTING"
120+
)
121+
88122
def computeGuSourceFeedExcl(
89123
showPAAPI: Boolean,
90124
guSourceFeeds: List[String],
@@ -93,8 +127,8 @@ object SearchParams {
93127
if (guSourceFeeds.nonEmpty || guSourceFeedsExcl.nonEmpty) {
94128
guSourceFeedsExcl
95129
} else if (showPAAPI) {
96-
Nil
130+
legacyPaSourceFeeds
97131
} else
98-
List("PA_API", "PA_API DATA FORMATTING")
132+
newPaSourceFeeds
99133
}
100134
}

newswires/test/models/SearchParamsSpec.scala

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@ class SearchParamsSpec extends AnyFlatSpec with models {
1414

1515
behavior of "build"
1616

17-
it should "return empty search params when none are set with default supplier exclusion set" in new searchParamsMocks {
17+
it should "return empty search params when none are set with default supplier and source feed exclusions set" in new searchParamsMocks {
1818
SearchParams.build(
1919
emptyQueryString,
2020
emptyBaseParams,
2121
featureSwitchesOn
2222
)(FakeRequest()) shouldEqual emptySearchParams.copy(filters =
23-
emptyFilterParams.copy(suppliersExcl = List("UNAUTHED_EMAIL_FEED"))
23+
emptyFilterParams.copy(
24+
suppliersExcl = List("UNAUTHED_EMAIL_FEED"),
25+
guSourceFeedsExcl = SearchParams.legacyPaSourceFeeds
26+
)
2427
)
2528
}
2629
it should "set an english search term when maybeFreeTextQuery is set" in new searchParamsMocks {
@@ -59,7 +62,9 @@ class SearchParamsSpec extends AnyFlatSpec with models {
5962
maybeEnd = Some("end"),
6063
maybeBeforeTimeStamp = Some("2023-01-01T00:00:00Z"),
6164
maybeAfterTimeStamp = Some("2023-01-02T00:00:00Z"),
62-
hasDataFormatting = Some(true)
65+
hasDataFormatting = Some(true),
66+
guSourceFeeds = List("A"),
67+
guSourceFeedsExcl = List("B")
6368
)
6469
val result = SearchParams.build(
6570
emptyQueryString,
@@ -84,8 +89,8 @@ class SearchParamsSpec extends AnyFlatSpec with models {
8489
collectionId = Some(1),
8590
preComputedCategories = Nil,
8691
preComputedCategoriesExcl = Nil,
87-
guSourceFeeds = Nil,
88-
guSourceFeedsExcl = Nil
92+
guSourceFeeds = List("A"),
93+
guSourceFeedsExcl = List("B")
8994
),
9095
DateRange(
9196
start = Some("start"),
@@ -108,6 +113,16 @@ class SearchParamsSpec extends AnyFlatSpec with models {
108113
)
109114
}
110115

116+
it should "include new PA API feed exclusions when the showPAAPI feature switch is off " in new searchParamsMocks {
117+
val result =
118+
SearchParams.build(
119+
emptyQueryString,
120+
emptyBaseParams,
121+
showPAAPIFeatureOff
122+
)(FakeRequest())
123+
result.filters.guSourceFeedsExcl shouldEqual SearchParams.newPaSourceFeeds
124+
}
125+
111126
behavior of "computeSupplierExcl"
112127

113128
it should "return dotcopy exclusion when no additional exclusion params are set and showGuSuppliers is true" in new searchParamsMocks {
@@ -188,7 +203,7 @@ class SearchParamsSpec extends AnyFlatSpec with models {
188203
guSourceFeeds = Nil,
189204
guSourceFeedsExcl = Nil
190205
)
191-
result shouldEqual Nil
206+
result shouldEqual SearchParams.legacyPaSourceFeeds
192207
}
193208
it should "be possible to override PA_API exclusions with guSourceFeedExcl param" in new searchParamsMocks {
194209
val result = SearchParams.computeGuSourceFeedExcl(

0 commit comments

Comments
 (0)