Skip to content

feat(projects): add case-insensitive project lookup by name - #575

Open
CollinsC1O wants to merge 3 commits into
HubDApp:mainfrom
CollinsC1O:p-search
Open

feat(projects): add case-insensitive project lookup by name#575
CollinsC1O wants to merge 3 commits into
HubDApp:mainfrom
CollinsC1O:p-search

Conversation

@CollinsC1O

Copy link
Copy Markdown
Contributor

Summary

Closes #518

Adds get_project_by_name(name) for case-insensitive project
lookups, backed by a new ProjectByNormalizedName storage index instead of
a full scan via list_projects.

  • storage_keys.rs: new ProjectByNormalizedName(String) key
  • utils.rs: Utils::normalize_name — ASCII-lowercases a name (safe since
    names are already restricted to alphanumeric/_/-)
  • project_registry.rs: register_project / update_project keep the
    normalized index in sync with the existing name index (set on create,
    remove+set on rename); new get_project_by_name does index lookup →
    get_project(id), mirroring get_project_by_slug
  • storage_manager.rs: TTL extension for the new index, wired into
    registration, update, and extend_project_full_ttl
  • lib.rs: exposes get_project_by_name as a contract entry point
  • tests/name_search.rs: exact match, case-insensitive variants,
    nonexistent name, no cross-project collisions, lookup after rename

Note: the issue described ProjectByNormalizedName as an existing index —
it wasn't; only the exact-match ProjectByName existed. This PR adds the
normalized index and its maintenance code.

Test plan

  • cargo test name_search once the branch's pre-existing, unrelated
    build breakage is fixed (see below) — verified manually via temporary
    local stubs that the new code compiles and the logic is correct
  • Exercise get_project_by_name on testnet with mixed-case input

Known 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_event are referenced but don't
exist anywhere in the codebase, and tests/mod.rs declares
error_handling_tests with no matching file. Flagging for visibility;
happy to fix in a follow-up if desired.

Collins C Augustine and others added 3 commits August 24, 2026 02:36
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

enhancement: add project search by normalized name

1 participant