Implement filterable endpoint for all parties
This commit is contained in:
parent
2a40abf08f
commit
af8b9d3570
1 changed files with 8 additions and 6 deletions
|
|
@ -2,10 +2,6 @@ class Api::V1::PartiesController < Api::V1::ApiController
|
||||||
before_action :set_from_slug, except: ['create', 'update']
|
before_action :set_from_slug, except: ['create', 'update']
|
||||||
before_action :set, only: ['update', 'destroy']
|
before_action :set, only: ['update', 'destroy']
|
||||||
|
|
||||||
def index
|
|
||||||
parties = Party.all
|
|
||||||
end
|
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@party = Party.new(shortcode: random_string)
|
@party = Party.new(shortcode: random_string)
|
||||||
@party.extra = party_params['extra']
|
@party.extra = party_params['extra']
|
||||||
|
|
@ -53,8 +49,14 @@ class Api::V1::PartiesController < Api::V1::ApiController
|
||||||
render :characters, status: :ok
|
render :characters, status: :ok
|
||||||
end
|
end
|
||||||
|
|
||||||
def all
|
def index
|
||||||
@parties = Party.all()
|
element = request.params['element']
|
||||||
|
raid = request.params['raid']
|
||||||
|
recency = request.params['recency'] ? Time.at(request.params['recency']).to_datetime.beginning_of_day : nil
|
||||||
|
now = DateTime.current
|
||||||
|
|
||||||
|
@parties = Party.where(element: element, raid_id: raid, created_at: recency..now)
|
||||||
|
|
||||||
render :all, status: :ok
|
render :all, status: :ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue