Skip to content

feat: Add OR logic support to user fetch API filters#789

Open
socksprox wants to merge 1 commit intocedar2025:masterfrom
socksprox:feat/or-filter-logic
Open

feat: Add OR logic support to user fetch API filters#789
socksprox wants to merge 1 commit intocedar2025:masterfrom
socksprox:feat/or-filter-logic

Conversation

@socksprox
Copy link

Summary

Added support for OR logic between filters in the user/fetch endpoint while maintaining full backward compatibility with existing API clients.

Features

  • Each filter can now specify a 'logic' parameter ('and' or 'or')
  • Defaults to 'and' when not specified (backward compatible)
  • Enables complex queries like finding users in multiple groups
  • Supports mixing AND/OR conditions in a single request

Examples

Find users in multiple groups (OR logic)

{
  "filter": [
    {
      "id": "group_id",
      "value": [1, 2, 3, 4],
      "logic": "or"
    }
  ]
}

Find users with high traffic OR expired accounts

{
  "filter": [
    {
      "id": "total_used",
      "value": "gt:107374182400"
    },
    {
      "id": "expired_at",
      "value": "lt:1706400000",
      "logic": "or"
    }
  ]
}

Backward compatible (legacy format still works)

{
  "filter": [
    {
      "id": "id",
      "value": "gt:13"
    },
    {
      "id": "total_used",
      "value": "gt:10737418240"
    }
  ]
}

Changes

  • Modified applyFilters method in UserController.php to support optional logic parameter
  • When logic is not specified, defaults to 'and' (preserves existing behavior)
  • When logic: 'or' is specified, uses orWhere instead of where

Backward Compatibility

✅ All existing API calls continue to work without any changes
✅ Legacy frontends require no modifications
✅ Only new requests with explicit logic: 'or' will use OR logic

@socksprox
Copy link
Author

@cedar2025 👀make sure not to forget my pull requests :)

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