From 92eb8259f50ada5ca39494b62408aba98e39288d Mon Sep 17 00:00:00 2001 From: psuzn Date: Fri, 7 Jun 2024 15:48:19 +0545 Subject: [PATCH] delete deal if detail scrap fails --- .../playdeals/jobs/AndroidAppDetailScrapper.kt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/backend/src/main/kotlin/me/sujanpoudel/playdeals/jobs/AndroidAppDetailScrapper.kt b/backend/src/main/kotlin/me/sujanpoudel/playdeals/jobs/AndroidAppDetailScrapper.kt index aaee7de..b530e10 100644 --- a/backend/src/main/kotlin/me/sujanpoudel/playdeals/jobs/AndroidAppDetailScrapper.kt +++ b/backend/src/main/kotlin/me/sujanpoudel/playdeals/jobs/AndroidAppDetailScrapper.kt @@ -63,6 +63,7 @@ class AppDetailScrapper( val app = loggingExecutionTime("$SIMPLE_NAME:: scrapping app details $packageName") { getAppDetail(packageName) }.getOrElse { + repository.delete(packageName) throw RuntimeException("AppDetailScrapper failed to scrap details ${it.message}") } @@ -121,10 +122,9 @@ class AppDetailScrapper( id = packageName, name = combined.getValue(Value.TITLE), icon = combined.getValue(Value.ICON), - images = - (combined.getValue(Value.SCREENSHOTS_LIST) as JsonArray).mapNotNull { - getValue(it as JsonArray, Value.SCREENSHOTS_URL.path.toTypedArray()) as? String - }, + images = (combined.getValue(Value.SCREENSHOTS_LIST) as JsonArray).mapNotNull { + getValue(it as JsonArray, Value.SCREENSHOTS_URL.path.toTypedArray()) as? String + }, normalPrice = normalPrice, currency = combined.getValue(Value.CURRENCY) as String, currentPrice = currentPrice, @@ -132,10 +132,9 @@ class AppDetailScrapper( downloads = combined.getValue(Value.INSTALLS), storeUrl = "https://play.google.com/store/apps/details?id=$packageName", category = combined.getValue(Value.GENRE) as String, - offerExpiresIn = - combined.getValueOrNull(Value.OFFER_END_TIME)?.let { - OffsetDateTime.ofInstant(Instant.ofEpochSecond(it.toLong()), ZoneOffset.UTC) - }, + offerExpiresIn = combined.getValueOrNull(Value.OFFER_END_TIME)?.let { + OffsetDateTime.ofInstant(Instant.ofEpochSecond(it.toLong()), ZoneOffset.UTC) + }, source = Constants.DealSources.APP_DEAL_SUBREDDIT, ) }