Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backend] Fetch Questions Sorted by Recent or Top-Rated Options #662

Open
7 tasks
atakanyasar opened this issue Dec 10, 2024 · 0 comments
Open
7 tasks

[Backend] Fetch Questions Sorted by Recent or Top-Rated Options #662

atakanyasar opened this issue Dec 10, 2024 · 0 comments
Labels
component: backend About backend priority: medium Medium priority type: enhancement New feature or request

Comments

@atakanyasar
Copy link
Contributor

📌 Feature: Add sortBy Parameter to Search Questions API


🏡 Component

  • Backend

📚 Detailed Description

Enhance the /search/questions endpoint to allow sorting of search results by different criteria using a new query parameter sortBy. This will enable fetching questions in either "recent" or "top-rated" order. It is needed for compatibility for pagination in mobile.

Existing Endpoint Specification

/search/questions:
  get:
    tags:
      - search
    summary: Search questions
    operationId: searchQuestions
    parameters:
      - name: q
        in: query
        description: Search query
        required: true
        schema:
          type: string
      - name: tags
        in: query
        description: Comma-separated list of tag IDs
        schema:
          type: string
      - name: difficulty
        in: query
        description: Filter by difficulty level
        schema:
          $ref: '#/components/schemas/DifficultyLevel'
      - name: page
        in: query
        description: Page number
        schema:
          type: integer
          default: 1
      - name: pageSize
        in: query
        description: Number of items per page
        schema:
          type: integer
          default: 20

📝 Proposed Changes

  • Add sortBy parameter: Introduce a new query parameter sortBy to the /search/questions endpoint. This will allow sorting the results by either recent or top-rated.

    • Type: string
    • Default: recent
    • Possible Values: recent, top-rated
  • Update API behavior: Modify the existing API logic to account for the sortBy parameter and return questions sorted by the selected value.

  • Default sorting: If sortBy is not provided, the API should default to recent sorting.

  • Adjust result order: Ensure that the returned questions are ordered according to the specified sortBy parameter, overriding the page-by-page ordering.

Schema:

type: string
enum:
  - recent
  - top-rated
default: recent      

📋 Acceptance Criteria

  • The sortBy parameter should be added to the /search/questions endpoint.
  • The sortBy parameter can accept values "recent" or "top-rated".
  • The results should be sorted according to the value of the sortBy parameter (either recent or top-rated).
  • If sortBy is not provided, the results should default to "recent".
  • The API response should return questions in the specified sort order (either by recent or top-rated).
  • The sortBy parameter should work together with other parameters like q, tags, difficulty, page, and pageSize.
  • Questions should be in order overall, not page-by-page.

👁‍🗨 Reviewer

@atakanyasar

@atakanyasar atakanyasar added type: enhancement New feature or request priority: medium Medium priority component: backend About backend labels Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: backend About backend priority: medium Medium priority type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant