Skip to content

bug: campaigns API state filter is ignored — always returns live campaigns #43

@Jing-yilin

Description

@Jing-yilin

Description

The GET /api/campaigns?state=successful endpoint ignores the state query parameter and always returns state='live' campaigns.

Root Cause

In backend/internal/handler/campaigns.go:64, the DB query hardcodes:

q := db.DB.Where("state = 'live' AND deadline >= ?", time.Now())

The state query parameter is never applied to the WHERE clause.

Expected Behavior

?state=successful should return only successful campaigns, ?state=live only live, etc.

Steps to Reproduce

curl 'https://api-dev.kickwatch.rescience.com/api/campaigns?state=successful&limit=3'
# Returns live campaigns instead of successful ones

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendBackend relatedbugSomething isn't workingpriority:mediumMedium priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions