Skip to content

Commit

Permalink
Show results if already scanned
Browse files Browse the repository at this point in the history
If the Dragonfly API returns a 409, then make another request to check
if the package has results already. If it does, then simply display
those results. If it doesn't, then that means the package is currently
in a "queued" or "pending" state. We can just send a feedback message
saying this in this case.
  • Loading branch information
Robin5605 committed Jan 6, 2024
1 parent 1c886dc commit 573ece1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/bot/exts/dragonfly/dragonfly.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,17 @@ async def queue(self: Self, ctx: commands.Context, name: str, version: str) -> N
await ctx.send(f"Package `{name} v{version}` was not found on PyPI")

if status_code == HTTPStatus.CONFLICT:
await ctx.send(f"Package `{name} v{version}` is already queued")
scan_results: list[PackageScanResult] = await self.bot.dragonfly_services.get_scanned_packages(
name=name,
version=version,
)
package = scan_results[0] if scan_results else None

if package:
embed = _build_package_scan_result_embed(scan_results[0])
await ctx.send(f"Package `{name} v{version}` has already been scanned.", embed=embed)
else:
await ctx.send(f"Package `{name} v{version}` is already waiting to be scanned.")
except Exception as e:
await ctx.send(str(e))
raise
Expand Down

0 comments on commit 573ece1

Please sign in to comment.