Skip to content

Commit

Permalink
Merge pull request #271 from bbc/revert-270-conal/merge_guardian_chan…
Browse files Browse the repository at this point in the history
…ges-180424

Revert "Merge latest Guardian changes as of 18-04-2024"
  • Loading branch information
Conalb97 authored Apr 18, 2024
2 parents 28c36e9 + 192a1c8 commit a77664c
Show file tree
Hide file tree
Showing 28 changed files with 54 additions and 233 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
push:
branches:
- main
- pr*
- 'pr**'
jobs:
CI:
runs-on: ubuntu-latest
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/push-pr.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: push-pr
run-name: Create/Update pr${{ inputs.prNumber }} branch
on:
workflow_dispatch:
inputs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ object MappingTest {
composerUrl = Some(new URI("https://composer/api/2345678987654321345678"))
)),
syndicationUsageMetadata = Some(SyndicationUsageMetadata(
partnerName = "friends of ours",
syndicatedBy = Some("Bob")
partnerName = "friends of ours"
)),
frontUsageMetadata = Some(FrontUsageMetadata(
addedBy = "me",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,7 @@ object Mappings {
))

def syndicationUsageMetadata(name: String): ObjectField = nonDynamicObjectField(name).copy(properties = Seq(
keywordField("partnerName"),
keywordField("syndicatedBy")
keywordField("partnerName")
))

def frontUsageMetadata(name: String): ObjectField = nonDynamicObjectField(name).copy(properties = Seq(
Expand All @@ -294,7 +293,7 @@ object Mappings {
keywordField("downloadedBy")
))

def usagesMapping(name: String): NestedField = nestedField(name).copy(properties = Seq(
def usagesMapping(name: String): NestedField = nestedField(name).copy( properties = Seq(
keywordField("id"),
sStemmerAnalysed("title"),
usageReference("references"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.gu.mediaservice.lib.usage

import java.net.URI

import com.amazonaws.services.dynamodbv2.document.Item
import com.gu.mediaservice.model.usage._
import org.joda.time.DateTime
Expand Down Expand Up @@ -51,8 +52,7 @@ object ItemToMediaUsage {
private def buildSyndication(metadataMap: Map[String, Any]): Option[SyndicationUsageMetadata] = {
Try {
SyndicationUsageMetadata(
metadataMap("partnerName").asInstanceOf[String],
metadataMap.get("syndicatedBy").map(x => x.asInstanceOf[String])
metadataMap("partnerName").asInstanceOf[String]
)
}.toOption
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ object UsageBuilder {
private def buildSyndicationUsageReference(usage: MediaUsage): List[UsageReference] = usage.syndicationUsageMetadata.map (metadata => {
List(
UsageReference(
SyndicationUsageReference, None, metadata.syndicatedBy.map(_ => s"${metadata.partnerName}, ${metadata.syndicatedBy.get}").orElse(Some(metadata.partnerName))
SyndicationUsageReference, None, Some(metadata.partnerName)
)
)
}).getOrElse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ object ExternalThrallMessage{
implicit val updateImagePhotoshootMetadataMessage = Json.format[UpdateImagePhotoshootMetadataMessage]
implicit val deleteUsagesMessage = Json.format[DeleteUsagesMessage]
implicit val deleteSingleUsageMessage = Json.format[DeleteSingleUsageMessage]
implicit val updateUsageStatusMessage = Json.format[UpdateUsageStatusMessage]
implicit val updateImageUsagesMessage = Json.format[UpdateImageUsagesMessage]
implicit val addImageLeaseMessage = Json.format[AddImageLeaseMessage]
implicit val removeImageLeaseMessage = Json.format[RemoveImageLeaseMessage]
Expand Down Expand Up @@ -125,8 +124,6 @@ case class DeleteSingleUsageMessage(id: String, lastModified: DateTime, usageId:

case class DeleteUsagesMessage(id: String, lastModified: DateTime) extends ExternalThrallMessage

case class UpdateUsageStatusMessage(id: String, usageNotice: UsageNotice, lastModified: DateTime) extends ExternalThrallMessage

object DeleteUsagesMessage {
implicit val yourJodaDateReads = JodaReads.DefaultJodaDateTimeReads.map(d => d.withZone(DateTimeZone.UTC))
implicit val yourJodaDateWrites = JodaWrites.JodaDateTimeWrites
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ package com.gu.mediaservice.model.usage
import play.api.libs.json._

case class SyndicationUsageMetadata(
partnerName: String,
syndicatedBy: Option[String] = None
partnerName: String
) extends UsageMetadata {
override def toMap: Map[String, Any] = Map(
"partnerName" -> partnerName
) ++ syndicatedBy.map("syndicatedBy" -> _)
)
}

object SyndicationUsageMetadata {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ sealed trait UsageStatus {
case RemovedUsageStatus => "removed"
case SyndicatedUsageStatus => "syndicated"
case DownloadedUsageStatus => "downloaded"
case FailedUsageStatus => "failed"
case UnknownUsageStatus => "unknown"
}
}
Expand All @@ -21,9 +20,7 @@ object UsageStatus {
case "removed" => RemovedUsageStatus
case "syndicated" => SyndicatedUsageStatus
case "downloaded" => DownloadedUsageStatus
case "failed" => FailedUsageStatus
case "unknown" => UnknownUsageStatus
case _ => throw new IllegalArgumentException("Invalid usage status")
}

implicit val reads: Reads[UsageStatus] = JsPath.read[String].map(UsageStatus(_))
Expand All @@ -38,7 +35,6 @@ object PublishedUsageStatus extends UsageStatus
object RemovedUsageStatus extends UsageStatus
object SyndicatedUsageStatus extends UsageStatus
object DownloadedUsageStatus extends UsageStatus
object FailedUsageStatus extends UsageStatus

// For Fronts usages as we don't know if a front is in draft or is live
// TODO remove this once we do!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ trait MessageSubjects {
val AddImageLease = "add-image-lease"
val RemoveImageLease = "remove-image-lease"
val SetImageCollections = "set-image-collections"
val UpdateUsageStatus = "update-usage-status"
val DeleteUsages = "delete-usages"
val DeleteSingleUsage = "delete-single-usage"
val UpdateImageSyndicationMetadata = "update-image-syndication-metadata"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@
<dd class="image-info__title"
ng-if="!ctrl.hasMultipleValues(ctrl.rawMetadata.title)">
<a ui-sref="search.results({query: (ctrl.metadata.title | queryFilter:'title'), nonFree: ctrl.srefNonfree()})"
ng-click="ctrl.searchWithModifiers($event, 'title', ctrl.metadata.title)"
aria-label="Search images by {{ctrl.metadata.title}} title">{{ctrl.metadata.title}}</a>
</dd>
</div>
Expand All @@ -113,7 +112,6 @@
<dd class="image-info__title"
ng-if="!ctrl.hasMultipleValues(ctrl.rawMetadata.title)">
<a ui-sref="search.results({query: (ctrl.metadata.title | queryFilter:'title'), nonFree: ctrl.srefNonfree()})"
ng-click="ctrl.searchWithModifiers($event, 'title', ctrl.metadata.title)"
aria-label="Search images by {{ctrl.metadata.title}} title">{{ctrl.metadata.title}}</a>
</dd>
</div>
Expand Down Expand Up @@ -324,7 +322,6 @@
<span class="metadata-line__info" ng-if="!ctrl.hasMultipleValues(ctrl.rawMetadata.byline)">
<span ng-if="ctrl.metadata.byline">
<a ui-sref="search.results({query: (ctrl.metadata.byline | queryFilter:'by'), nonFree: ctrl.srefNonfree()})"
ng-click="ctrl.searchWithModifiers($event, 'by', ctrl.metadata.byline)"
aria-label="Search images by {{ctrl.metadata.byline}} byline">{{ctrl.metadata.byline}}</a>
</span>

Expand Down Expand Up @@ -373,7 +370,6 @@
<span class="metadata-line__info" ng-if="!ctrl.hasMultipleValues(ctrl.rawMetadata.credit)">
<span ng-if="ctrl.metadata.credit">
<a ui-sref="search.results({query: (ctrl.metadata.credit | queryFilter:'credit'), nonFree: ctrl.srefNonfree()})"
ng-click="ctrl.searchWithModifiers($event, 'credit', ctrl.metadata.credit)"
aria-label="Search images by {{ctrl.metadata.credit}} credit">{{ctrl.metadata.credit}}</a>
</span>

Expand Down Expand Up @@ -404,7 +400,6 @@
<a
ng-if="!ctrl.hasMultipleValues(ctrl.rawMetadata[prop])"
ui-sref="search.results({query: (ctrl.metadata[prop] | queryFilter:ctrl.locationFieldMap[prop]), nonFree: ctrl.srefNonfree()})"
ng-click="ctrl.searchWithModifiers($event, ctrl.locationFieldMap[prop], ctrl.metadata[prop])"
aria-label="Search images by {{ctrl.metadata[prop]}} {{prop}}"
>{{ctrl.metadata[prop]}}</a><span
ng-if="ctrl.hasMultipleValues(ctrl.rawMetadata[prop])"
Expand Down Expand Up @@ -543,7 +538,6 @@
<span class="metadata-line__info" ng-if="!ctrl.hasMultipleValues(ctrl.rawMetadata.copyright)">
<span ng-if="ctrl.metadata.copyright">
<a ui-sref="search.results({query: (ctrl.metadata.copyright | queryFilter:'copyright'), nonFree: ctrl.srefNonfree()})"
ng-click="ctrl.searchWithModifiers($event, 'copyright', ctrl.metadata.copyright)"
aria-label="Search images by {{ctrl.metadata.copyright}} copyright">{{ctrl.metadata.copyright}}</a>
</span>

Expand All @@ -565,7 +559,6 @@
<dd ng-if="!ctrl.hasMultipleValues(ctrl.extraInfo.uploadedBy)" class="image-info__wrap metadata-line metadata-line__info image-info__group--dl__value--panel">
<span class="metadata-line__info">
<a ui-sref="search.results({query: (ctrl.extraInfo.uploadedBy | queryFilter:'uploader'), nonFree: ctrl.srefNonfree()})"
ng-click="ctrl.searchWithModifiers($event, 'uploader', ctrl.extraInfo.uploadedBy)"
aria-label="Search images uploaded by {{ctrl.extraInfo.uploadedBy}}">{{ctrl.extraInfo.uploadedBy | stripEmailDomain}}</a>
</span>
</dd>
Expand Down Expand Up @@ -646,7 +639,6 @@
<dt class="metadata-line__key image-info__group--dl__key--full-metadata">{{key | spaceWords}}</dt>
<dd class="metadata-line__info image-info__group--dl__value--full-metadata">
<a ui-sref="search.results({query: (value | queryFilter:'{{key}}'), nonFree: ctrl.srefNonfree()})"
ng-click="ctrl.searchWithModifiers($event, key, value)"
aria-label="Search images with {{key}} '{{value}}'">{{value}}</a>
</dd>
</dl>
Expand All @@ -655,7 +647,6 @@
<dt class="metadata-line__key image-info__group--dl__key--full-metadata">{{key}}</dt>
<dd class="metadata-line__info image-info__group--dl__value--full-metadata">
<a ui-sref="search.results({query: (metadata.value | queryFilter:'{{metadata.alias}}'), nonFree: ctrl.srefNonfree()})"
ng-click="ctrl.searchWithModifiers($event, metadata.alias, metadata.value)"
aria-label="Search images with {{key}} '{{metadata.value}}'">{{metadata.value}}</a>
</dd>
</dl>
Expand Down Expand Up @@ -841,7 +832,6 @@
ng-repeat="collection in ctrl.singleImage.data.collections"
ng-switch-default>
<a ui-sref="search.results({query: (collection.data.pathId | queryCollectionFilter), nonFree: ctrl.srefNonfree()})"
ng-click="ctrl.searchWithModifiers($event, 'collection', collection.data.pathId)"
aria-label="Search images by {{collection.data.description}} collection">
{{collection.data.path.join(' ▸ ')}}
</a>
Expand Down
Loading

0 comments on commit a77664c

Please sign in to comment.