in src/main/scala/ophan/google/indexing/observatory/model/AvailabilityRecord.scala [57:75]
def apply(resolved: Resolution.Resolved, firstSeenInSitemap: Instant): AvailabilityRecord = AvailabilityRecord(
uri = resolved.redirectPath.originalUri,
uriResolvedOk = resolved.conclusion.isOk,
finalUriAfterRedirects = resolved.redirectPath.locations.tail.lastOption,
firstSeenInSitemap = firstSeenInSitemap
)
implicit val uriAsStringFormat: DynamoFormat[URI] =
DynamoFormat.coercedXmap[URI, String, URISyntaxException](new URI(_), _.toString)
implicit val instantAsISO8601StringFormat: DynamoFormat[Instant] =
DynamoFormat.coercedXmap[Instant, String, DateTimeParseException](Instant.parse, _.truncatedTo(SECONDS).toString)
implicit class RichDynamoValue(dv: DynamoValue) {
def plusObjectEntry(keyValue: (String, String)): DynamoValue = {
val (key, value) = keyValue
dv.withObject(_.add(key, DynamoValue.fromString(value)).toDynamoValue)
}
}