Compare commits

...

2 commits

Author SHA1 Message Date
tejaswini chile
fbb642e13d fix: current_page metadata 2022-07-28 00:58:44 +05:30
tejaswini chile
aa991b3cd3 fix: help center clearing minor bugs 2022-07-20 13:36:10 +05:30
11 changed files with 42 additions and 1 deletions

View file

@ -2,6 +2,7 @@ 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
@ -49,4 +50,8 @@ class Api::V1::Accounts::ArticlesController < Api::V1::Accounts::BaseController
:category_slug, :locale, :query, :page
)
end
def set_current_page
@current_page = params[:page] || 1
end
end

View file

@ -2,6 +2,7 @@ class Api::V1::Accounts::CategoriesController < Api::V1::Accounts::BaseControlle
before_action :portal
before_action :check_authorization
before_action :fetch_category, except: [:index, :create]
before_action :set_current_page, only: [:index]
def index
@categories = @portal.categories.search(params)
@ -49,4 +50,8 @@ class Api::V1::Accounts::CategoriesController < Api::V1::Accounts::BaseControlle
:name, :description, :position, :slug, :locale, :parent_category_id, :associated_category_id
)
end
def set_current_page
@current_page = params[:page] || 1
end
end

View file

@ -3,6 +3,7 @@ class Api::V1::Accounts::PortalsController < Api::V1::Accounts::BaseController
before_action :fetch_portal, except: [:index, :create]
before_action :check_authorization
before_action :set_current_page, only: [:index]
def index
@portals = Current.account.portals
@ -66,4 +67,8 @@ class Api::V1::Accounts::PortalsController < Api::V1::Accounts::BaseController
def portal_member_params
params.require(:portal).permit(:account_id, member_ids: [])
end
def set_current_page
@current_page = params[:page] || 1
end
end

View file

@ -5,6 +5,7 @@
# id :bigint not null, primary key
# content :text
# description :text
# meta :jsonb
# status :integer
# title :string
# views :integer

View file

@ -1,3 +1,8 @@
json.payload do
json.array! @articles, partial: 'article', as: :article
end
json.meta do
json.current_page @current_page
json.articles_count @articles.size
end

View file

@ -25,3 +25,5 @@ if category.root_category.present?
json.partial! 'api/v1/accounts/categories/associated_category.json.jbuilder', category: category.root_category
end
end
json.articles_count category.articles.published.try(:count)

View file

@ -1,3 +1,8 @@
json.payload do
json.array! @categories, partial: 'category', as: :category
end
json.meta do
json.current_page @current_page
json.categories_count @categories.size
end

View file

@ -1,3 +1,8 @@
json.payload do
json.array! @portals, partial: 'portal', as: :portal
end
json.meta do
json.current_page @current_page
json.portals_count @portals.size
end

View file

@ -23,3 +23,5 @@ if category.root_category.present?
json.partial! partial: 'associated_category', category: category.root_category
end
end
json.articles_count category.articles.published.try(:count)

View file

@ -0,0 +1,5 @@
class AddMetaColumnToArticle < ActiveRecord::Migration[6.1]
def change
add_column :articles, :meta, :jsonb, default: {}
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2022_07_18_123938) do
ActiveRecord::Schema.define(version: 2022_07_20_080126) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_stat_statements"
@ -128,6 +128,7 @@ ActiveRecord::Schema.define(version: 2022_07_18_123938) do
t.datetime "updated_at", precision: 6, null: false
t.bigint "author_id"
t.bigint "associated_article_id"
t.jsonb "meta", default: {}
t.index ["associated_article_id"], name: "index_articles_on_associated_article_id"
t.index ["author_id"], name: "index_articles_on_author_id"
end