Skip to content

Commit

Permalink
delete deal if detail scrap fails (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
psuzn authored Jun 7, 2024
1 parent 846f0c3 commit 0672490
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
}

Expand Down Expand Up @@ -121,21 +122,19 @@ 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,
rating = combined.getValue<Float>(Value.RATINGS).toString(),
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<Int>(Value.OFFER_END_TIME)?.let {
OffsetDateTime.ofInstant(Instant.ofEpochSecond(it.toLong()), ZoneOffset.UTC)
},
offerExpiresIn = combined.getValueOrNull<Int>(Value.OFFER_END_TIME)?.let {
OffsetDateTime.ofInstant(Instant.ofEpochSecond(it.toLong()), ZoneOffset.UTC)
},
source = Constants.DealSources.APP_DEAL_SUBREDDIT,
)
}
Expand Down

0 comments on commit 0672490

Please sign in to comment.