From a7b6a8ecfefdc9ca716b34aaf90239ff48d2f1f0 Mon Sep 17 00:00:00 2001 From: Joe Cowton Date: Thu, 30 Jun 2022 08:44:46 +0100 Subject: [PATCH 1/3] Update naming --- article/app/topics/TopicS3Client.scala | 12 ++++---- article/app/topics/TopicService.scala | 4 +-- article/test/LiveBlogControllerTest.scala | 28 +++++++++---------- .../test/model/LiveBlogCurrentPageTest.scala | 16 +++++------ article/test/topics/TopicServiceTest.scala | 26 ++++++++--------- common/app/model/TopMentionsModel.scala | 20 ++++++------- common/test/model/TopMentionsModelTest.scala | 14 +++++----- 7 files changed, 60 insertions(+), 60 deletions(-) diff --git a/article/app/topics/TopicS3Client.scala b/article/app/topics/TopicS3Client.scala index b30b66747584..2179ae5a90ff 100644 --- a/article/app/topics/TopicS3Client.scala +++ b/article/app/topics/TopicS3Client.scala @@ -5,7 +5,7 @@ import com.amazonaws.services.s3.model.{GetObjectRequest, S3Object} import com.amazonaws.util.IOUtils import common.GuLogging import conf.Configuration -import model.{TopMentionJsonParseException, TopicsApiResponse} +import model.{TopicsJsonParseException, TopicsApiResponse} import play.api.libs.json.{JsError, JsSuccess, Json} import services.S3 import topics.S3ObjectImplicits.RichS3Object @@ -46,7 +46,7 @@ final class TopicS3ClientImpl extends TopicS3Client with S3 with GuLogging { client.getObject(request).parseToTopicsApiResponse }.flatten match { case Success(value) => - log.info(s"got topMentionResponse from S3 for key ${key}") + log.info(s"got topicApiResponse from S3 for key ${key}") Future.successful(value) case Failure(exception) => log.error(s"S3 retrieval failed for key ${key}", exception) @@ -75,14 +75,14 @@ object S3ObjectImplicits { Json.fromJson[TopicsApiResponse](json) match { case JsSuccess(topMentionResponse, __) => - log.debug(s"Parsed TopMentionsDetails from S3 for key ${s3Object.getKey}") + log.debug(s"Parsed TopicDetails from S3 for key ${s3Object.getKey}") Success(topMentionResponse) case JsError(errors) => val errorPaths = errors.map { error => error._1.toString() }.mkString(",") - log.error(s"Error parsing topMentionResponse from S3 for key ${s3Object.getKey} paths: ${errorPaths}") + log.error(s"Error parsing topicApiResponse from S3 for key ${s3Object.getKey} paths: ${errorPaths}") Failure( - TopMentionJsonParseException( - s"could not parse S3 TopMentionsDetails json. Errors paths(s): $errors", + TopicsJsonParseException( + s"could not parse S3 TopicDetails json. Errors paths(s): $errors", ), ) } diff --git a/article/app/topics/TopicService.scala b/article/app/topics/TopicService.scala index 4f732dc98096..b19c7d8106a5 100644 --- a/article/app/topics/TopicService.scala +++ b/article/app/topics/TopicService.scala @@ -10,9 +10,9 @@ class TopicService(topicS3Client: TopicS3Client) extends GuLogging { private val topicsDetails = Box[Option[Map[String, TopicsApiResponse]]](None) def refreshTopics()(implicit executionContext: ExecutionContext): Future[Unit] = { - val retrievedTopMentions = topicS3Client.getListOfKeys().map { key => key.map { retrieveTopicsDetails(_) } } + val retrievedTopics = topicS3Client.getListOfKeys().map { key => key.map { retrieveTopicsDetails(_) } } - retrievedTopMentions + retrievedTopics .flatMap(Future.sequence(_)) .map(response => { topicsDetails send Some(response.toMap) diff --git a/article/test/LiveBlogControllerTest.scala b/article/test/LiveBlogControllerTest.scala index 3514c698484e..8b6266ff402f 100644 --- a/article/test/LiveBlogControllerTest.scala +++ b/article/test/LiveBlogControllerTest.scala @@ -9,7 +9,7 @@ import play.api.test._ import play.api.test.Helpers._ import org.scalatest.{BeforeAndAfterAll, DoNotDiscover} import org.scalatestplus.mockito.MockitoSugar -import model.{LiveBlogPage, TopicResult, SelectedTopic, TopMentionsTopicType, AvailableTopic, TopicsLiveBlog} +import model.{LiveBlogPage, TopicResult, SelectedTopic, TopicType, AvailableTopic, TopicsLiveBlog} import topics.{TopicS3Client, TopicService} import scala.concurrent.Future @@ -33,27 +33,27 @@ import scala.concurrent.Future var fakeDcr = new DCRFake() val topicResult = TopicResult( name = "Fifa", - `type` = TopMentionsTopicType.Org, + `type` = TopicType.Org, blocks = Seq("56d08042e4b0d38537b1f70b"), count = 1, percentage_blocks = 1.2f, ) val fakeAvailableTopics = Vector( - AvailableTopic(TopMentionsTopicType.Gpe, "United Kingdom", 6), - AvailableTopic(TopMentionsTopicType.Gpe, "Russia", 4), - AvailableTopic(TopMentionsTopicType.Org, "KPMG", 4), - AvailableTopic(TopMentionsTopicType.Gpe, "Ukraine", 3), - AvailableTopic(TopMentionsTopicType.Gpe, "China", 2), - AvailableTopic(TopMentionsTopicType.Gpe, "United States", 2), - AvailableTopic(TopMentionsTopicType.Loc, "Europe", 2), - AvailableTopic(TopMentionsTopicType.Gpe, "Moscow", 2), - AvailableTopic(TopMentionsTopicType.Org, "PZ Cussons", 2), - AvailableTopic(TopMentionsTopicType.Person, "Emmanuel Macron", 1), + AvailableTopic(TopicType.Gpe, "United Kingdom", 6), + AvailableTopic(TopicType.Gpe, "Russia", 4), + AvailableTopic(TopicType.Org, "KPMG", 4), + AvailableTopic(TopicType.Gpe, "Ukraine", 3), + AvailableTopic(TopicType.Gpe, "China", 2), + AvailableTopic(TopicType.Gpe, "United States", 2), + AvailableTopic(TopicType.Loc, "Europe", 2), + AvailableTopic(TopicType.Gpe, "Moscow", 2), + AvailableTopic(TopicType.Org, "PZ Cussons", 2), + AvailableTopic(TopicType.Person, "Emmanuel Macron", 1), ); when( - fakeTopicService.getSelectedTopic(path, SelectedTopic(TopMentionsTopicType.Org, "Fifa")), + fakeTopicService.getSelectedTopic(path, SelectedTopic(TopicType.Org, "Fifa")), ) thenReturn Some( topicResult, ) @@ -314,7 +314,7 @@ import scala.concurrent.Future assertDcrCalledForLiveBlogWithBlocks(fakeDcr, expectedBlocks = Seq("56d08042e4b0d38537b1f70b")) } - "renderArticle" should "doesn't call getTopMentionsByTopic given filterKeyEvents and topics query params are provided" in new Setup { + "renderArticle" should "doesn't call getSelectedTopic given filterKeyEvents and topics query params are provided" in new Setup { val fakeRequest = FakeRequest(GET, s"${path}").withHeaders("host" -> "localhost:9000") val result = liveBlogController.renderArticle( diff --git a/article/test/model/LiveBlogCurrentPageTest.scala b/article/test/model/LiveBlogCurrentPageTest.scala index 590ba5e004b0..67c978e00e91 100644 --- a/article/test/model/LiveBlogCurrentPageTest.scala +++ b/article/test/model/LiveBlogCurrentPageTest.scala @@ -2,7 +2,7 @@ package model import model.liveblog.BodyBlock.{KeyEvent, SummaryEvent} import model.liveblog._ -import model.TopMentionsTopicType.TopMentionsTopicType +import model.TopicType.TopicType import org.joda.time.DateTime import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers @@ -65,7 +65,7 @@ class LiveBlogCurrentPageTest extends AnyFlatSpec with Matchers { filterKeyEvents = false, topicResult = Some( TopicResult( - `type` = TopMentionsTopicType.Org, + `type` = TopicType.Org, name = "someName", blocks = Seq(), count = 0, @@ -376,7 +376,7 @@ class LiveBlogCurrentPageTest extends AnyFlatSpec with Matchers { } it should "only filters blocks by key events given both key events and top mentions are provided" in { - val topicResult = getFakeTopicResult(TopMentionsTopicType.Org, "tfl", Seq("1", "3")) + val topicResult = getFakeTopicResult(TopicType.Org, "tfl", Seq("1", "3")) val testFakeBlocks = TestFakeBlocks(numberOfBlocks = 5, numberOfKeyEventsBlocks = 2, None) val result = LiveBlogCurrentPage.firstPage( @@ -400,7 +400,7 @@ class LiveBlogCurrentPageTest extends AnyFlatSpec with Matchers { } it should "returns the 1st page of the topic filtered blocks" in { - val topicResult = getFakeTopicResult(TopMentionsTopicType.Org, "tfl", Seq("1", "2", "3", "4")) + val topicResult = getFakeTopicResult(TopicType.Org, "tfl", Seq("1", "2", "3", "4")) val testFakeBlocks = TestFakeBlocks(numberOfBlocks = 5, numberOfKeyEventsBlocks = 2, None) val result = LiveBlogCurrentPage.firstPage( @@ -670,7 +670,7 @@ class LiveBlogCurrentPageTest extends AnyFlatSpec with Matchers { } it should "returns the correct 2nd page of the topic filtered blocks" in { - val topicResult = getFakeTopicResult(TopMentionsTopicType.Org, "tfl", Seq("2", "3", "4", "5", "6")) + val topicResult = getFakeTopicResult(TopicType.Org, "tfl", Seq("2", "3", "4", "5", "6")) val testFakeBlocks = TestFakeBlocks(numberOfBlocks = 8, numberOfKeyEventsBlocks = 2, None) val expectedFirstPage = FirstPage( @@ -707,7 +707,7 @@ class LiveBlogCurrentPageTest extends AnyFlatSpec with Matchers { } "updates" should "return only the topic filtered blocks after the lastUpdated block given lastUpdated is also a topic block" in { - val topicResult = getFakeTopicResult(TopMentionsTopicType.Org, "tfl", Seq("2", "3", "4", "5", "6")) + val topicResult = getFakeTopicResult(TopicType.Org, "tfl", Seq("2", "3", "4", "5", "6")) val sinceBlock = SinceBlockId("5") val testFakeBlocks = TestFakeBlocks(numberOfBlocks = 8, numberOfKeyEventsBlocks = 2, Some("5")) @@ -723,7 +723,7 @@ class LiveBlogCurrentPageTest extends AnyFlatSpec with Matchers { } "updates" should "return only the topic filtered blocks after the lastUpdated block given lastUpdated is NOT a topic block" in { - val topicResult = getFakeTopicResult(TopMentionsTopicType.Org, "tfl", Seq("2", "3", "5", "6")) + val topicResult = getFakeTopicResult(TopicType.Org, "tfl", Seq("2", "3", "5", "6")) val sinceBlockId = "4" val testFakeBlocks = TestFakeBlocks(numberOfBlocks = 8, numberOfKeyEventsBlocks = 2, Some(sinceBlockId)) @@ -740,7 +740,7 @@ class LiveBlogCurrentPageTest extends AnyFlatSpec with Matchers { } private def getFakeTopicResult( - topicType: TopMentionsTopicType, + topicType: TopicType, topicName: String, blocks: Seq[String], ) = { diff --git a/article/test/topics/TopicServiceTest.scala b/article/test/topics/TopicServiceTest.scala index 89d14e98ce46..5dd11383baf0 100644 --- a/article/test/topics/TopicServiceTest.scala +++ b/article/test/topics/TopicServiceTest.scala @@ -1,6 +1,6 @@ package topics -import model.{TopicsApiResponse, TopicResult, SelectedTopic, TopMentionsTopicType, AvailableTopic} +import model.{TopicsApiResponse, TopicResult, SelectedTopic, TopicType, AvailableTopic} import org.scalatest.{BeforeAndAfterAll} import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers @@ -22,7 +22,7 @@ class TopicServiceTest val topicResult = TopicResult( name = "name1", - `type` = TopMentionsTopicType.Org, + `type` = TopicType.Org, blocks = Seq("blockId1"), count = 1, percentage_blocks = 1.2f, @@ -31,24 +31,24 @@ class TopicServiceTest val topicResults = Seq( TopicResult( name = "name1", - `type` = TopMentionsTopicType.Org, + `type` = TopicType.Org, blocks = Seq("blockId1"), count = 1, percentage_blocks = 1.2f, ), TopicResult( name = "name2", - `type` = TopMentionsTopicType.Person, + `type` = TopicType.Person, blocks = Seq("blockId1"), count = 10, percentage_blocks = 1.2f, ), ) val successResponse = - TopicsApiResponse(entity_types = Seq(TopMentionsTopicType.Org), results = Seq(topicResult), model = "model") + TopicsApiResponse(entity_types = Seq(TopicType.Org), results = Seq(topicResult), model = "model") val successMultiResponse = - TopicsApiResponse(entity_types = Seq(TopMentionsTopicType.Org), results = topicResults, model = "model") + TopicsApiResponse(entity_types = Seq(TopicType.Org), results = topicResults, model = "model") "refreshTopics" should "return successful future given getListOfKeys s3 call fails" in { when(fakeClient.getListOfKeys()) thenReturn Future.failed(new Throwable("")) @@ -95,7 +95,7 @@ class TopicServiceTest val topicService = new TopicService(fakeClient) val refreshJob = Await.result(topicService.refreshTopics(), 1.second) - val result = topicService.getSelectedTopic("key1", SelectedTopic(TopMentionsTopicType.Org, "name1")) + val result = topicService.getSelectedTopic("key1", SelectedTopic(TopicType.Org, "name1")) result.get should equal(topicResult) } @@ -107,7 +107,7 @@ class TopicServiceTest val topicService = new TopicService(fakeClient) val refreshJob = Await.result(topicService.refreshTopics(), 1.second) - val result = topicService.getSelectedTopic("key1", SelectedTopic(TopMentionsTopicType.Org, "NAME1")) + val result = topicService.getSelectedTopic("key1", SelectedTopic(TopicType.Org, "NAME1")) result should equal(None) } @@ -119,7 +119,7 @@ class TopicServiceTest val topicService = new TopicService(fakeClient) val refreshJob = Await.result(topicService.refreshTopics(), 1.second) - val result = topicService.getSelectedTopic("key2", SelectedTopic(TopMentionsTopicType.Org, "name1")) + val result = topicService.getSelectedTopic("key2", SelectedTopic(TopicType.Org, "name1")) result should equal(None) } @@ -132,7 +132,7 @@ class TopicServiceTest val refreshJob = Await.result(topicService.refreshTopics(), 1.second) val result = - topicService.getSelectedTopic("key1", SelectedTopic(TopMentionsTopicType.Person, "Boris")) + topicService.getSelectedTopic("key1", SelectedTopic(TopicType.Person, "Boris")) result should equal(None) } @@ -145,7 +145,7 @@ class TopicServiceTest val refreshJob = Await.result(topicService.refreshTopics(), 1.second) val result = - topicService.getSelectedTopic("key1", SelectedTopic(TopMentionsTopicType.Org, "someRandomOrg")) + topicService.getSelectedTopic("key1", SelectedTopic(TopicType.Org, "someRandomOrg")) result should equal(None) } @@ -156,8 +156,8 @@ class TopicServiceTest val expectedTopics = Some( List( - AvailableTopic(TopMentionsTopicType.Org, "name1", 1), - AvailableTopic(TopMentionsTopicType.Person, "name2", 10), + AvailableTopic(TopicType.Org, "name1", 1), + AvailableTopic(TopicType.Person, "name2", 10), ), ) diff --git a/common/app/model/TopMentionsModel.scala b/common/app/model/TopMentionsModel.scala index d7ab4780b80b..e12052c1221d 100644 --- a/common/app/model/TopMentionsModel.scala +++ b/common/app/model/TopMentionsModel.scala @@ -1,19 +1,19 @@ package model import common.GuLogging -import model.TopMentionsTopicType.TopMentionsTopicType +import model.TopicType.TopicType import play.api.libs.json.{Format, Json} case class TopicResult( name: String, - `type`: TopMentionsTopicType, + `type`: TopicType, blocks: Seq[String], count: Int, percentage_blocks: Float, ) -case class TopicsApiResponse(entity_types: Seq[TopMentionsTopicType], results: Seq[TopicResult], model: String) +case class TopicsApiResponse(entity_types: Seq[TopicType], results: Seq[TopicResult], model: String) -case class TopMentionJsonParseException(message: String) extends Exception(message) +case class TopicsJsonParseException(message: String) extends Exception(message) object TopicsApiResponse { implicit val TopicResultJf: Format[TopicResult] = Json.format[TopicResult] @@ -21,7 +21,7 @@ object TopicsApiResponse { } case class AvailableTopic( - `type`: TopMentionsTopicType, + `type`: TopicType, value: String, count: Int, ) @@ -30,7 +30,7 @@ object AvailableTopic { implicit val AvailableTopicJf: Format[AvailableTopic] = Json.format[AvailableTopic] } -case class SelectedTopic(`type`: TopMentionsTopicType, value: String) +case class SelectedTopic(`type`: TopicType, value: String) object SelectedTopic extends GuLogging { @@ -40,7 +40,7 @@ object SelectedTopic extends GuLogging { topic.flatMap { f => val filterEntity = f.split(":") if (filterEntity.length == 2) { - val entityType = TopMentionsTopicType.withNameOpt(filterEntity(0)) + val entityType = TopicType.withNameOpt(filterEntity(0)) if (entityType.isEmpty) { log.warn(s"topics query parameter entity ${filterEntity(0)} is invalid") None @@ -56,8 +56,8 @@ object SelectedTopic extends GuLogging { } } -object TopMentionsTopicType extends Enumeration { - type TopMentionsTopicType = Value +object TopicType extends Enumeration { + type TopicType = Value val Org = Value(1, "ORG") val Product = Value(2, "PRODUCT") @@ -68,5 +68,5 @@ object TopMentionsTopicType extends Enumeration { def withNameOpt(s: String): Option[Value] = values.find(_.toString == s.toUpperCase) - implicit val format: Format[TopMentionsTopicType] = Json.formatEnum(this) + implicit val format: Format[TopicType] = Json.formatEnum(this) } diff --git a/common/test/model/TopMentionsModelTest.scala b/common/test/model/TopMentionsModelTest.scala index da9f6e9b8541..0e45f51434a8 100644 --- a/common/test/model/TopMentionsModelTest.scala +++ b/common/test/model/TopMentionsModelTest.scala @@ -3,7 +3,7 @@ package model import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -class TopMentionsModelTest extends AnyFlatSpec with Matchers { +class TopicsModelTest extends AnyFlatSpec with Matchers { "getFilterEntityFromTopicsParam" should "return none when no topic is provided" in { val result = SelectedTopic.fromString(None) @@ -17,7 +17,7 @@ class TopMentionsModelTest extends AnyFlatSpec with Matchers { result should be(None) } - it should "return none when the provided topic does not exist as a valid TopMentionsTopicType" in { + it should "return none when the provided topic does not exist as a valid TopicType" in { val topic = Some("organization:nhs") val result = SelectedTopic.fromString(topic) @@ -26,11 +26,11 @@ class TopMentionsModelTest extends AnyFlatSpec with Matchers { it should "be case insensitive on topic type" in { val topics = Seq( - TestCase("ORG:someEntityValue", SelectedTopic(TopMentionsTopicType.Org, "someEntityValue")), - TestCase("Org:someEntityValue", SelectedTopic(TopMentionsTopicType.Org, "someEntityValue")), - TestCase("Product:someEntityValue", SelectedTopic(TopMentionsTopicType.Product, "someEntityValue")), - TestCase("PRODUCT:someEntityValue", SelectedTopic(TopMentionsTopicType.Product, "someEntityValue")), - TestCase("person:someEntityValue", SelectedTopic(TopMentionsTopicType.Person, "someEntityValue")), + TestCase("ORG:someEntityValue", SelectedTopic(TopicType.Org, "someEntityValue")), + TestCase("Org:someEntityValue", SelectedTopic(TopicType.Org, "someEntityValue")), + TestCase("Product:someEntityValue", SelectedTopic(TopicType.Product, "someEntityValue")), + TestCase("PRODUCT:someEntityValue", SelectedTopic(TopicType.Product, "someEntityValue")), + TestCase("person:someEntityValue", SelectedTopic(TopicType.Person, "someEntityValue")), ) topics foreach { topic => val result = SelectedTopic.fromString(Some(topic.topic)) From dbda1e6e51c042d93418a1c717a41e54656eb944 Mon Sep 17 00:00:00 2001 From: Joe Cowton Date: Thu, 30 Jun 2022 09:09:37 +0100 Subject: [PATCH 2/3] More renaming --- article/app/topics/TopicS3Client.scala | 12 ++++++------ article/app/topics/TopicService.scala | 12 ++++++------ article/test/model/LiveBlogCurrentPageTest.scala | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/article/app/topics/TopicS3Client.scala b/article/app/topics/TopicS3Client.scala index 2179ae5a90ff..5c11df9e2641 100644 --- a/article/app/topics/TopicS3Client.scala +++ b/article/app/topics/TopicS3Client.scala @@ -30,10 +30,10 @@ final class TopicS3ClientImpl extends TopicS3Client with S3 with GuLogging { s3ObjectList.map(_.getKey) } match { case Success(value) => - log.info(s"got list of ${value.length} top mentions from S3") + log.info(s"got list of ${value.length} topics from S3") Future.successful(value) case Failure(exception) => - log.error(s"failed in getting the list of top mentions from S3", exception) + log.error(s"failed in getting the list of topics from S3", exception) Future.failed(exception) } } @@ -57,14 +57,14 @@ final class TopicS3ClientImpl extends TopicS3Client with S3 with GuLogging { private def getBucket() = { optionalBucket.getOrElse( - throw new RuntimeException("top mention bucket config is empty, make sure config parameter has value"), + throw new RuntimeException("topics bucket config is empty, make sure config parameter has value"), ) } private def getClient[T](callS3: AmazonS3 => Future[T]) = { client .map { callS3(_) } - .getOrElse(Future.failed(new RuntimeException("No client exist for TopicS3Client"))) + .getOrElse(Future.failed(new RuntimeException("No client exists for TopicS3Client"))) } } @@ -74,9 +74,9 @@ object S3ObjectImplicits { val json = Json.parse(asString(s3Object)) Json.fromJson[TopicsApiResponse](json) match { - case JsSuccess(topMentionResponse, __) => + case JsSuccess(topicsApiResponse, __) => log.debug(s"Parsed TopicDetails from S3 for key ${s3Object.getKey}") - Success(topMentionResponse) + Success(topicsApiResponse) case JsError(errors) => val errorPaths = errors.map { error => error._1.toString() }.mkString(",") log.error(s"Error parsing topicApiResponse from S3 for key ${s3Object.getKey} paths: ${errorPaths}") diff --git a/article/app/topics/TopicService.scala b/article/app/topics/TopicService.scala index b19c7d8106a5..400b7db9dfb4 100644 --- a/article/app/topics/TopicService.scala +++ b/article/app/topics/TopicService.scala @@ -16,11 +16,11 @@ class TopicService(topicS3Client: TopicS3Client) extends GuLogging { .flatMap(Future.sequence(_)) .map(response => { topicsDetails send Some(response.toMap) - log.info("successfully refreshed top mentions") + log.info("successfully refreshed topics") }) .recover { case e => - log.error("Could not refresh top mentions", e) + log.error("Could not refresh topics", e) } } @@ -29,8 +29,8 @@ class TopicService(topicS3Client: TopicS3Client) extends GuLogging { } def getAvailableTopics(blogId: String): Option[Seq[AvailableTopic]] = { - getBlogTopicsApiResponse(blogId).map(mentions => - mentions.results.map(mention => AvailableTopic(mention.`type`, mention.name, mention.count)), + getBlogTopicsApiResponse(blogId).map(topicsApiResponse => + topicsApiResponse.results.map(topic => AvailableTopic(topic.`type`, topic.name, topic.count)), ) } @@ -40,10 +40,10 @@ class TopicService(topicS3Client: TopicS3Client) extends GuLogging { def getSelectedTopic( blogId: String, - topMentionEntity: SelectedTopic, + topicEntity: SelectedTopic, ): Option[TopicResult] = { getBlogTopicsApiResponse(blogId).flatMap(_.results.find(result => { - result.`type` == topMentionEntity.`type` && result.name == topMentionEntity.value + result.`type` == topicEntity.`type` && result.name == topicEntity.value })) } diff --git a/article/test/model/LiveBlogCurrentPageTest.scala b/article/test/model/LiveBlogCurrentPageTest.scala index 67c978e00e91..92914d40704f 100644 --- a/article/test/model/LiveBlogCurrentPageTest.scala +++ b/article/test/model/LiveBlogCurrentPageTest.scala @@ -375,7 +375,7 @@ class LiveBlogCurrentPageTest extends AnyFlatSpec with Matchers { should(result, currentPage = expectedCurrentPage, pagination = expectedPagination) } - it should "only filters blocks by key events given both key events and top mentions are provided" in { + it should "only filters blocks by key events given both key events and topicResult are provided" in { val topicResult = getFakeTopicResult(TopicType.Org, "tfl", Seq("1", "3")) val testFakeBlocks = TestFakeBlocks(numberOfBlocks = 5, numberOfKeyEventsBlocks = 2, None) val result = From a22f4bea20558a9e127a8748a70c90e79820de90 Mon Sep 17 00:00:00 2001 From: Joe Cowton Date: Thu, 30 Jun 2022 09:19:01 +0100 Subject: [PATCH 3/3] More renaming --- article/app/topics/TopicS3Client.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/article/app/topics/TopicS3Client.scala b/article/app/topics/TopicS3Client.scala index 5c11df9e2641..1724b2a615f4 100644 --- a/article/app/topics/TopicS3Client.scala +++ b/article/app/topics/TopicS3Client.scala @@ -46,7 +46,7 @@ final class TopicS3ClientImpl extends TopicS3Client with S3 with GuLogging { client.getObject(request).parseToTopicsApiResponse }.flatten match { case Success(value) => - log.info(s"got topicApiResponse from S3 for key ${key}") + log.info(s"got TopicsApiResponse from S3 for key ${key}") Future.successful(value) case Failure(exception) => log.error(s"S3 retrieval failed for key ${key}", exception) @@ -75,14 +75,14 @@ object S3ObjectImplicits { Json.fromJson[TopicsApiResponse](json) match { case JsSuccess(topicsApiResponse, __) => - log.debug(s"Parsed TopicDetails from S3 for key ${s3Object.getKey}") + log.debug(s"Parsed TopicsApiResponse from S3 for key ${s3Object.getKey}") Success(topicsApiResponse) case JsError(errors) => val errorPaths = errors.map { error => error._1.toString() }.mkString(",") - log.error(s"Error parsing topicApiResponse from S3 for key ${s3Object.getKey} paths: ${errorPaths}") + log.error(s"Error parsing TopicsApiResponse from S3 for key ${s3Object.getKey} paths: ${errorPaths}") Failure( TopicsJsonParseException( - s"could not parse S3 TopicDetails json. Errors paths(s): $errors", + s"could not parse S3 TopicsApiResponse json. Errors paths(s): $errors", ), ) }