From 781acad918f6222bdb692b84539413ccc3987296 Mon Sep 17 00:00:00 2001 From: Nihal Mirpuri Date: Wed, 16 Oct 2024 22:04:04 +0100 Subject: [PATCH 1/3] Add random UUID to bypass cache --- src/main/scala/plex/PlexUtils.scala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/scala/plex/PlexUtils.scala b/src/main/scala/plex/PlexUtils.scala index 8ce9cbb..adc4b3c 100644 --- a/src/main/scala/plex/PlexUtils.scala +++ b/src/main/scala/plex/PlexUtils.scala @@ -13,6 +13,8 @@ import io.circe.generic.extras.auto._ import io.circe.syntax.EncoderOps import org.http4s.client.UnexpectedStatus +import java.util.UUID + trait PlexUtils { private val logger = LoggerFactory.getLogger(getClass) @@ -21,7 +23,10 @@ trait PlexUtils { extras.Configuration.default.withDefaults protected def fetchWatchlistFromRss(client: HttpClient)(url: Uri): IO[Set[Item]] = { - val jsonFormatUrl = url.withQueryParam("format", "json") + val randomUUID = UUID.randomUUID().toString.take(5) + val jsonFormatUrl = url + .withQueryParam("format", "json") + .withQueryParam(randomUUID, randomUUID) client.httpRequest(Method.GET, jsonFormatUrl).map { case Left(UnexpectedStatus(s, _, _)) if s.code == 500 => From 6fbeca2a90731aff887a08499ea2426b57e44d13 Mon Sep 17 00:00:00 2001 From: Nihal Mirpuri Date: Wed, 16 Oct 2024 22:11:04 +0100 Subject: [PATCH 2/3] make unit tests more generic --- src/test/scala/plex/PlexUtilsSpec.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/scala/plex/PlexUtilsSpec.scala b/src/test/scala/plex/PlexUtilsSpec.scala index 7763a13..0a824ca 100644 --- a/src/test/scala/plex/PlexUtilsSpec.scala +++ b/src/test/scala/plex/PlexUtilsSpec.scala @@ -23,7 +23,7 @@ class PlexUtilsSpec extends AnyFlatSpec with Matchers with PlexUtils with MockFa (mockClient.httpRequest _) .expects( Method.GET, - Uri.unsafeFromString("http://localhost:9090?format=json"), + *, None, None ) @@ -40,7 +40,7 @@ class PlexUtilsSpec extends AnyFlatSpec with Matchers with PlexUtils with MockFa (mockClient.httpRequest _) .expects( Method.GET, - Uri.unsafeFromString("http://localhost:9090?format=json"), + *, None, None ) From dbb5e384767da3e944632788309f9a99a5ad1c40 Mon Sep 17 00:00:00 2001 From: Nihal Mirpuri Date: Wed, 16 Oct 2024 22:12:10 +0100 Subject: [PATCH 3/3] review notes --- src/main/scala/plex/PlexUtils.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/plex/PlexUtils.scala b/src/main/scala/plex/PlexUtils.scala index adc4b3c..e569527 100644 --- a/src/main/scala/plex/PlexUtils.scala +++ b/src/main/scala/plex/PlexUtils.scala @@ -23,10 +23,10 @@ trait PlexUtils { extras.Configuration.default.withDefaults protected def fetchWatchlistFromRss(client: HttpClient)(url: Uri): IO[Set[Item]] = { - val randomUUID = UUID.randomUUID().toString.take(5) + val randomUUID = UUID.randomUUID().toString.take(12) val jsonFormatUrl = url .withQueryParam("format", "json") - .withQueryParam(randomUUID, randomUUID) + .withQueryParam("cache_buster", randomUUID) client.httpRequest(Method.GET, jsonFormatUrl).map { case Left(UnexpectedStatus(s, _, _)) if s.code == 500 =>