Skip to content

Commit

Permalink
Remove ID from filterable paths #5825
Browse files Browse the repository at this point in the history
  • Loading branch information
StepanBrychta committed Dec 3, 2024
1 parent 0b00044 commit 153c8a6
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 31 deletions.
24 changes: 12 additions & 12 deletions search/src/main/scala/weco/api/search/rest/ImagesParams.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ case class MultipleImagesParams(
query: Option[String],
license: Option[LicenseFilter],
`source.contributors.agent.label`: Option[ContributorsLabelFilter],
`source.contributors.agent.id`: Option[ContributorsIdFilter],
`source.contributors.agent`: Option[ContributorsIdFilter],
`source.genres.label`: Option[GenreLabelFilter],
`source.genres.id`: Option[GenreIdFilter],
`source.genres`: Option[GenreIdFilter],
`source.subjects.label`: Option[SubjectLabelFilter],
`source.subjects.id`: Option[SubjectIdFilter],
`source.subjects`: Option[SubjectIdFilter],
`source.production.dates.from`: Option[LocalDate],
`source.production.dates.to`: Option[LocalDate],
color: Option[RgbColor],
Expand All @@ -75,11 +75,11 @@ case class MultipleImagesParams(
List(
license,
`source.contributors.agent.label`,
`source.contributors.agent.id`,
`source.contributors.agent`,
`source.genres.label`,
`source.genres.id`,
`source.genres`,
`source.subjects.label`,
`source.subjects.id`,
`source.subjects`,
dateFilter
).flatten

Expand All @@ -102,11 +102,11 @@ object MultipleImagesParams extends QueryParamsUtils {
"query".as[String].?,
"locations.license".as[LicenseFilter].?,
"source.contributors.agent.label".as[ContributorsLabelFilter].?,
"source.contributors.agent.id".as[ContributorsIdFilter].?,
"source.contributors.agent".as[ContributorsIdFilter].?,
"source.genres.label".as[GenreLabelFilter].?,
"source.genres.id".as[GenreIdFilter].?,
"source.genres".as[GenreIdFilter].?,
"source.subjects.label".as[SubjectLabelFilter].?,
"source.subjects.id".as[SubjectIdFilter].?,
"source.subjects".as[SubjectIdFilter].?,
"source.production.dates.from".as[LocalDate].?,
"source.production.dates.to".as[LocalDate].?,
"color".as[RgbColor].?,
Expand Down Expand Up @@ -139,11 +139,11 @@ object MultipleImagesParams extends QueryParamsUtils {
decodeOneOfCommaSeparated(
"locations.license" -> ImageAggregationRequest.License,
"source.contributors.agent.label" -> ImageAggregationRequest.SourceContributorAgentsLabel,
"source.contributors.agent.id" -> ImageAggregationRequest.SourceContributorAgentsId,
"source.contributors.agent" -> ImageAggregationRequest.SourceContributorAgentsId,
"source.genres.label" -> ImageAggregationRequest.SourceGenresLabel,
"source.genres.id" -> ImageAggregationRequest.SourceGenresId,
"source.genres" -> ImageAggregationRequest.SourceGenresId,
"source.subjects.label" -> ImageAggregationRequest.SourceSubjectsLabel,
"source.subjects.id" -> ImageAggregationRequest.SourceSubjectsId
"source.subjects" -> ImageAggregationRequest.SourceSubjectsId
)

implicit val sortDecoder: Decoder[List[SortRequest]] =
Expand Down
24 changes: 12 additions & 12 deletions search/src/main/scala/weco/api/search/rest/WorksParams.scala
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ case class WorkFilterParams(
`production.dates.to`: Option[LocalDate],
languages: Option[LanguagesFilter],
`genres.label`: Option[GenreLabelFilter],
`genres.id`: Option[GenreIdFilter],
`genres`: Option[GenreIdFilter],
`subjects.label`: Option[SubjectLabelFilter],
`subjects.id`: Option[SubjectIdFilter],
`subjects`: Option[SubjectIdFilter],
`contributors.agent.label`: Option[ContributorsLabelFilter],
`contributors.agent.id`: Option[ContributorsIdFilter],
`contributors.agent`: Option[ContributorsIdFilter],
identifiers: Option[IdentifiersFilter],
partOf: Option[PartOfFilter],
`partOf.title`: Option[PartOfTitleFilter],
Expand Down Expand Up @@ -120,11 +120,11 @@ case class MultipleWorksParams(
dateFilter,
filterParams.languages,
filterParams.`genres.label`,
filterParams.`genres.id`,
filterParams.`genres`,
filterParams.`subjects.label`,
filterParams.`subjects.id`,
filterParams.`subjects`,
filterParams.`contributors.agent.label`,
filterParams.`contributors.agent.id`,
filterParams.`contributors.agent`,
filterParams.identifiers,
itemsParams.`items`,
itemsParams.`items.identifiers`,
Expand Down Expand Up @@ -204,11 +204,11 @@ object MultipleWorksParams extends QueryParamsUtils {
"production.dates.to".as[LocalDate].?,
"languages".as[LanguagesFilter].?,
"genres.label".as[GenreLabelFilter].?,
"genres.id".as[GenreIdFilter].?,
"genres".as[GenreIdFilter].?,
"subjects.label".as[SubjectLabelFilter].?,
"subjects.id".as[SubjectIdFilter].?,
"subjects".as[SubjectIdFilter].?,
"contributors.agent.label".as[ContributorsLabelFilter].?,
"contributors.agent.id".as[ContributorsIdFilter].?,
"contributors.agent".as[ContributorsIdFilter].?,
"identifiers".as[IdentifiersFilter].?,
"partOf".as[PartOfFilter].?,
"partOf.title".as[PartOfTitleFilter].?,
Expand Down Expand Up @@ -303,13 +303,13 @@ object MultipleWorksParams extends QueryParamsUtils {
decodeOneOfCommaSeparated(
"workType" -> WorkAggregationRequest.Format,
"genres.label" -> WorkAggregationRequest.GenreLabel,
"genres.id" -> WorkAggregationRequest.GenreId,
"genres" -> WorkAggregationRequest.GenreId,
"production.dates" -> WorkAggregationRequest.ProductionDate,
"subjects.label" -> WorkAggregationRequest.SubjectLabel,
"subjects.id" -> WorkAggregationRequest.SubjectId,
"subjects" -> WorkAggregationRequest.SubjectId,
"languages" -> WorkAggregationRequest.Languages,
"contributors.agent.label" -> WorkAggregationRequest.ContributorLabel,
"contributors.agent.id" -> WorkAggregationRequest.ContributorId,
"contributors.agent" -> WorkAggregationRequest.ContributorId,
"items.locations.license" -> WorkAggregationRequest.License,
"availabilities" -> WorkAggregationRequest.Availabilities
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class ImagesFiltersTest extends AnyFunSpec with ApiImagesTestBase {
withGenreFilterRecords { routes =>
assertJsonResponse(
routes,
path = s"$rootPath/images?source.genres.id="
path = s"$rootPath/images?source.genres="
) {
Status.OK -> imagesListResponse(
ids = Seq(
Expand All @@ -150,7 +150,7 @@ class ImagesFiltersTest extends AnyFunSpec with ApiImagesTestBase {
withGenreFilterRecords { routes =>
assertJsonResponse(
routes,
path = s"$rootPath/images?source.genres.id=baadf00d"
path = s"$rootPath/images?source.genres=baadf00d"
) {
Status.OK -> imagesListResponse(
ids = Seq(
Expand All @@ -167,7 +167,7 @@ class ImagesFiltersTest extends AnyFunSpec with ApiImagesTestBase {
withGenreFilterRecords { routes =>
assertJsonResponse(
routes,
path = s"$rootPath/images?source.genres.id=g00dcafe,baadf00d"
path = s"$rootPath/images?source.genres=g00dcafe,baadf00d"
) {
Status.OK -> imagesListResponse(
ids = Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class WorksErrorsTest extends AnyFunSpec with ApiWorksTestBase with TableDrivenP
}

val aggregationsString =
"['workType', 'genres.label', 'genres.id', 'production.dates', 'subjects.label', 'subjects.id', 'languages', 'contributors.agent.label', 'contributors.agent.id', 'items.locations.license', 'availabilities']"
"['workType', 'genres.label', 'genres', 'production.dates', 'subjects.label', 'subjects', 'languages', 'contributors.agent.label', 'contributors.agent', 'items.locations.license', 'availabilities']"

describe(
"returns a 400 Bad Request for errors in the ?aggregations parameter"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class WorksFiltersTest
withGenreIdFilterRecords { routes =>
assertJsonResponse(
routes,
path = s"$rootPath/works?genres.id="
path = s"$rootPath/works?genres="
) {
Status.OK -> worksListResponse(
ids = Seq(
Expand All @@ -188,7 +188,7 @@ class WorksFiltersTest
withGenreIdFilterRecords { routes =>
assertJsonResponse(
routes,
path = s"$rootPath/works?genres.id=baadf00d"
path = s"$rootPath/works?genres=baadf00d"
) {
Status.OK -> worksListResponse(
ids = Seq(
Expand All @@ -206,7 +206,7 @@ class WorksFiltersTest
withGenreIdFilterRecords { routes =>
assertJsonResponse(
routes,
path = s"$rootPath/works?genres.id=g00dcafe,baadf00d"
path = s"$rootPath/works?genres=g00dcafe,baadf00d"
) {
Status.OK -> worksListResponse(
ids = Seq(
Expand Down

0 comments on commit 153c8a6

Please sign in to comment.