chore: Add articles metadata (#5125)

This commit is contained in:
Tejaswini Chile
2022-07-28 13:59:16 +05:30
committed by GitHub
parent 7f48cffeb3
commit 41df70fb96
19 changed files with 74 additions and 15 deletions

View File

@@ -2,10 +2,11 @@ class Api::V1::Accounts::ArticlesController < Api::V1::Accounts::BaseController
before_action :portal
before_action :check_authorization
before_action :fetch_article, except: [:index, :create]
before_action :set_current_page, only: [:index]
def index
@articles = @portal.articles
@articles = @articles.search(list_params) if params[:payload].present?
@articles = @articles.search(list_params) if list_params.present?
end
def create
@@ -45,8 +46,10 @@ class Api::V1::Accounts::ArticlesController < Api::V1::Accounts::BaseController
end
def list_params
params.require(:payload).permit(
:category_slug, :locale, :query, :page
)
params.permit(:locale, :query, :page, :category_slug)
end
def set_current_page
@current_page = params[:page] || 1
end
end