From 850a63e4fb718369f058c6d41056e9418915c917 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 | 13 +++++++------ 1 file changed, 7 insertions(+), 6 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..0b18641 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}") } @@ -122,9 +123,9 @@ class AppDetailScrapper( 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 - }, + (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, @@ -133,9 +134,9 @@ class AppDetailScrapper( 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) - }, + combined.getValueOrNull(Value.OFFER_END_TIME)?.let { + OffsetDateTime.ofInstant(Instant.ofEpochSecond(it.toLong()), ZoneOffset.UTC) + }, source = Constants.DealSources.APP_DEAL_SUBREDDIT, ) }