Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions newswires/app/models/SearchParams.scala
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,40 @@ object SearchParams {
dotCopyExclusion ::: guSuppliersExclusion ::: exclusionFromParams
}

val legacyPaSourceFeeds = List(
"PA PR NEWSWIRE",
"PA PA MEDIA PRESS CENTRES",
"PA PA MEDIA ASSIGNMENTS",
"PA BUSINESSWIRE",
"PA THE ACADEMY OF MEDICAL SCIENCES",
"PA PA SPORT LATEST",
"PA PRESSWIRE",
"PA PA",
"PA GLOBENEWSWIRE",
"PA EQS NEWSWIRE",
"PA LATEST",
"PA RESPONSESOURCE",
"PA ACCESS NEWSWIRE",
"PA UK GOVERNMENT AND PUBLIC SECTOR",
"PA PA SPORT",
"PA PA ADVISORY",
"PA AGILITY PR SOLUTIONS",
"PA NEWS AKTUELL",
"PA ADVISORY",
"PA MARKETTIERS",
"PA RNS",
"PA",
"PA PA SPORT SNAP",
"PA NEWSFILE",
"PA PRESSAT",
"PA SNAP"
)

val newPaSourceFeeds = List(
"PA_API",
"PA_API DATA FORMATTING"
)

def computeGuSourceFeedExcl(
showPAAPI: Boolean,
guSourceFeeds: List[String],
Expand All @@ -93,8 +127,8 @@ object SearchParams {
if (guSourceFeeds.nonEmpty || guSourceFeedsExcl.nonEmpty) {
guSourceFeedsExcl
} else if (showPAAPI) {
Nil
legacyPaSourceFeeds
} else
List("PA_API", "PA_API DATA FORMATTING")
newPaSourceFeeds
}
}
27 changes: 21 additions & 6 deletions newswires/test/models/SearchParamsSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ class SearchParamsSpec extends AnyFlatSpec with models {

behavior of "build"

it should "return empty search params when none are set with default supplier exclusion set" in new searchParamsMocks {
it should "return empty search params when none are set with default supplier and source feed exclusions set" in new searchParamsMocks {
SearchParams.build(
emptyQueryString,
emptyBaseParams,
featureSwitchesOn
)(FakeRequest()) shouldEqual emptySearchParams.copy(filters =
emptyFilterParams.copy(suppliersExcl = List("UNAUTHED_EMAIL_FEED"))
emptyFilterParams.copy(
suppliersExcl = List("UNAUTHED_EMAIL_FEED"),
guSourceFeedsExcl = SearchParams.legacyPaSourceFeeds
)
)
}
it should "set an english search term when maybeFreeTextQuery is set" in new searchParamsMocks {
Expand Down Expand Up @@ -59,7 +62,9 @@ class SearchParamsSpec extends AnyFlatSpec with models {
maybeEnd = Some("end"),
maybeBeforeTimeStamp = Some("2023-01-01T00:00:00Z"),
maybeAfterTimeStamp = Some("2023-01-02T00:00:00Z"),
hasDataFormatting = Some(true)
hasDataFormatting = Some(true),
guSourceFeeds = List("A"),
guSourceFeedsExcl = List("B")
)
val result = SearchParams.build(
emptyQueryString,
Expand All @@ -84,8 +89,8 @@ class SearchParamsSpec extends AnyFlatSpec with models {
collectionId = Some(1),
preComputedCategories = Nil,
preComputedCategoriesExcl = Nil,
guSourceFeeds = Nil,
guSourceFeedsExcl = Nil
guSourceFeeds = List("A"),
guSourceFeedsExcl = List("B")
),
DateRange(
start = Some("start"),
Expand All @@ -108,6 +113,16 @@ class SearchParamsSpec extends AnyFlatSpec with models {
)
}

it should "include new PA API feed exclusions when the showPAAPI feature switch is off " in new searchParamsMocks {
val result =
SearchParams.build(
emptyQueryString,
emptyBaseParams,
showPAAPIFeatureOff
)(FakeRequest())
result.filters.guSourceFeedsExcl shouldEqual SearchParams.newPaSourceFeeds
}

behavior of "computeSupplierExcl"

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