Skip to content

Commit

Permalink
fixes empty api search results (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
msramalho authored Dec 13, 2023
1 parent 98fb574 commit 128d413
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/auto_archiver/databases/api_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ def fetch(self, item: Metadata) -> Union[Metadata, bool]:
response = requests.get(os.path.join(self.api_endpoint, "tasks/search-url"), params=params, headers=headers)

if response.status_code == 200:
logger.success(f"API returned a previously archived instance: {response.json()}")
# TODO: can we do better than just returning the most recent result?
return Metadata.from_dict(response.json()[0]["result"])

logger.error(f"AA API FAIL ({response.status_code}): {response.json()}")
if len(response.json()):
logger.success(f"API returned a previously archived instance: {response.json()}")
# TODO: can we do better than just returning the most recent result?
return Metadata.from_dict(response.json()[0]["result"])
else:
logger.error(f"AA API FAIL ({response.status_code}): {response.json()}")
return False


Expand Down
2 changes: 1 addition & 1 deletion src/auto_archiver/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
_MINOR = "7"
# On main and in a nightly release the patch should be one ahead of the last
# released build.
_PATCH = "3"
_PATCH = "4"
# This is mainly for nightly builds which have the suffix ".dev$DATE". See
# https://semver.org/#is-v123-a-semantic-version for the semantics.
_SUFFIX = ""
Expand Down

0 comments on commit 128d413

Please sign in to comment.