feat(projects): add case-insensitive project lookup by name - #575
Open
CollinsC1O wants to merge 3 commits into
Open
feat(projects): add case-insensitive project lookup by name#575CollinsC1O wants to merge 3 commits into
CollinsC1O wants to merge 3 commits into
Conversation
Add a ProjectByNormalizedName index maintained alongside the existing ProjectByName index, and expose get_project_by_name() for O(1) case-insensitive lookups instead of a full project scan.
Dedupe the case-insensitive project name lookup with the normalized-name index main already added, remove leftover conflict markers and duplicate code from the botched stash-pop, and run cargo fmt across the crate. - cargo fmt --check: clean - cargo build: clean - cargo test: 586 passed, 0 failed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Closes #518
Adds
get_project_by_name(name)for case-insensitive projectlookups, backed by a new
ProjectByNormalizedNamestorage index instead ofa full scan via
list_projects.storage_keys.rs: newProjectByNormalizedName(String)keyutils.rs:Utils::normalize_name— ASCII-lowercases a name (safe sincenames are already restricted to alphanumeric/
_/-)project_registry.rs:register_project/update_projectkeep thenormalized index in sync with the existing name index (set on create,
remove+set on rename); new
get_project_by_namedoes index lookup →get_project(id), mirroringget_project_by_slugstorage_manager.rs: TTL extension for the new index, wired intoregistration, update, and
extend_project_full_ttllib.rs: exposesget_project_by_nameas a contract entry pointtests/name_search.rs: exact match, case-insensitive variants,nonexistent name, no cross-project collisions, lookup after rename
Note: the issue described
ProjectByNormalizedNameas an existing index —it wasn't; only the exact-match
ProjectByNameexisted. This PR adds thenormalized index and its maintenance code.
Test plan
cargo test name_searchonce the branch's pre-existing, unrelatedbuild breakage is fixed (see below) — verified manually via temporary
local stubs that the new code compiles and the logic is correct
get_project_by_nameon testnet with mixed-case inputKnown pre-existing issue (unrelated to this PR)
This branch currently fails to build/test independent of this change:
Utils::validate_project_slug,ContractError::ProjectSlugAlreadyExists,and
events::publish_featured_project_eventare referenced but don'texist anywhere in the codebase, and
tests/mod.rsdeclareserror_handling_testswith no matching file. Flagging for visibility;happy to fix in a follow-up if desired.