Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • G gitlabhq1
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 21
    • Issues 21
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • gpt
  • large_projects
  • gitlabhq1
  • Issues
  • #1575

Closed
Open
Created Sep 27, 2012 by Administrator@rootOwner

API Filters

Created by: onlymejosh

Hi,

I am trying to add filters to the API but I'm struggling with grape.

I am tyring to do something like this in lib/api/issues.rb

resource :issues do
      # Get currently authenticated user's issues
      # Parameters:
      #   state [closed|open] - The state of the issue  
      # Example Request:
      #   GET /issues
      get do
        if params[:state].present?
          issues = paginate(current_user.issues.where("closed = ?",params[:state]))
        else
          issues = paginate(current_user.issues)
        end
        present issues, with: Entities::Issue
      end
    end

current_user.issues returns an array opposed to an Active::Relation. Any guidance would be great :)

Assignee
Assign to
Time tracking