Repository navigation
Short job IDs: show, link and accept the UUID tail (#345) #430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a01d611
Short IDs: resolve UUID tails in reference inputs (#345)
rheos 703846d
Short IDs in Leads links and a visible Copy job ID button (#345)
rheos dcab30e
Short IDs: address the cold review on #430
rheos 0a567b9
Short IDs: let in-transaction lookup failures propagate
rheos f0d66fc
Drop a head-equality assertion that could flake (CodeRabbit, #430)
rheos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| """Short IDs for opportunities (#345): the UUID's random tail, lengthened on a clash.""" | ||
|
|
||
| from collections.abc import Iterable, Sequence | ||
| from typing import Any | ||
| from uuid import UUID | ||
|
|
||
| from rheo_core.refs.resolver import UnitOfWork | ||
| from rheo_core.refs.short import short_ids | ||
| from sqlalchemy import String, cast, func, select | ||
|
|
||
| from rheo_leads.storage import pipeline as p | ||
|
|
||
|
|
||
| def opportunity_tails(uow: UnitOfWork, length: int, tails: Sequence[str]) -> list[UUID]: | ||
| """Opportunities whose last ``length`` hex characters are one of ``tails``. | ||
|
|
||
| A scan, not an index: a workspace holds hundreds of opportunities, and an | ||
| expression index would be a module migration (#345). | ||
| """ | ||
| o = p.opportunity | ||
| tail = func.right(func.replace(cast(o.c.id, String), "-", ""), length) | ||
| return list( | ||
| uow.connection.execute(select(o.c.id).where(tail.in_(list(tails)))).scalars() | ||
| ) | ||
|
|
||
|
|
||
| def opportunity_short_ids(uow: UnitOfWork, ids: Iterable[UUID]) -> dict[UUID, str]: | ||
| return short_ids(uow, opportunity_tails, ids) | ||
|
|
||
|
|
||
| def with_short_ids( | ||
| uow: UnitOfWork, items: Sequence[dict[str, Any]], key: str = "id" | ||
| ) -> None: | ||
| """Set ``short_id`` on each item from its opportunity id under ``key``.""" | ||
| ids = [UUID(str(i[key])) for i in items if i.get(key) is not None] | ||
| shorts = opportunity_short_ids(uow, ids) | ||
| for item in items: | ||
| if item.get(key) is not None: | ||
| item["short_id"] = shorts[UUID(str(item[key]))] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.