Skip to content

Conversation

@adityaalifn
Copy link
Contributor

@adityaalifn adityaalifn commented Apr 15, 2025

Submit a pull request

CLA

  • I have signed the Stream CLA (required).
  • The code changes follow best practices
  • Code changes are tested (add some information if not applicable)

Description of the pull request

# Get threads created by a specific user, updated after a certain date,
# sorted by creation date (newest first), reply count (ascending), and participant count (descending)
response = client.query_threads(
  filter: {
    'created_by_user_id' => { '$eq' => 'user1' },
    'updated_at' => { '$gte' => '2024-01-01T00:00:00Z' }
  },
  sort: {
    'created_at' => -1,
    'reply_count' => 1,
    'participant_count' => -1
  },
  limit: 10
)

# Access the threads and next page token
threads = response['threads']
next_page_token = response['next']

# Request the next page
if next_page_token
  next_page_response = client.query_threads(
    filter: {
      'created_by_user_id' => { '$eq' => 'user1' },
      'updated_at' => { '$gte' => '2024-01-01T00:00:00Z' }
    },
    sort: {
      'created_at' => -1,
      'reply_count' => 1,
      'participant_count' => -1
    },
    limit: 10,
    next: next_page_token
  )
end

@adityaalifn adityaalifn merged commit cdad3b8 into master Apr 16, 2025
4 checks passed
@adityaalifn adityaalifn deleted the add-query-threads branch April 16, 2025 11:47
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.

2 participants