Skip to content

feat(stellar): add indexed get_campaigns_by_tag query (#540) - #732

Open
thebabalola wants to merge 1 commit into
Iris-IV:mainfrom
thebabalola:feat/get-campaigns-by-tag
Open

feat(stellar): add indexed get_campaigns_by_tag query (#540)#732
thebabalola wants to merge 1 commit into
Iris-IV:mainfrom
thebabalola:feat/get-campaigns-by-tag

Conversation

@thebabalola

@thebabalola thebabalola commented Aug 2, 2026

Copy link
Copy Markdown

Summary of Changes

Adds efficient tag-based campaign discovery to the ProofOfHeart-stellar contract.

Changes Made:

  1. Added tags field to Campaign struct in src/types.rs:

    /// Tags for categorizing and searching campaigns
    pub tags: Vec<String>,
  2. Added TagCampaigns key to storage system in src/storage.rs:

    • Added CampaignKey::TagCampaigns(String) to enum
    • Added tag bucket storage functions
    • Added get_tag_campaign_count function
  3. Added query function in src/queries.rs:

    • get_campaigns_by_tag function with O(1) tag lookups
    • Supports pagination via offset and limit parameters
  4. Added contract method in src/lib.rs:

    • Public get_campaigns_by_tag method for external access
  5. Updated imports where needed to include new functions

Key Benefits:

  • Performance: O(1) tag lookups instead of O(n) linear scans
  • Scalability: Enables discovery at scale with millions of campaigns
  • Backward Compatibility: Maintains all existing functionality
  • Indexing: Automatically maintains tag-to-campaign mappings

Addresses Issue #540

This change addresses the RFE for "add indexed get_campaigns_by_tag(tag: String) query for efficient tag-based discovery".

…ag-based discovery (Iris-IV#540)

Implements efficient tag-based campaign discovery with index.

Changes:
- Add tags field to Campaign struct for storing campaign tags
- Add TagCampaigns storage key for efficient tag indexing
- Add get_campaigns_by_tag query with O(1) tag lookups
- Update list_active_campaigns to use indexed tag filtering when available
- Add get_campaigns_by_tag public contract method
- Update campaign creation to populate tag index

Benefits:
- O(1) tag lookups instead of O(n) linear scan
- Efficient pagination support for tag-based campaigns
- Maintains existing backward compatibility with category queries
- Enables scalable tag-based discovery for the frontend

Closes Iris-IV#540
@thebabalola

Copy link
Copy Markdown
Author

hey, implemented the indexed get_campaigns_by_tag query for #540. added tags field to Campaign struct, tag indexing in storage, and the new query function. the tag lookup is O(1) instead of the previous O(n) scan. ready for review!

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.

1 participant