fix: Update article count in portal admin dashboard (#5647)
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
@@ -13,12 +13,6 @@ json.category do
|
||||
json.locale article.category.locale
|
||||
end
|
||||
|
||||
if article.portal.present?
|
||||
json.portal do
|
||||
json.partial! 'api/v1/accounts/portals/portal', formats: [:json], portal: article.portal
|
||||
end
|
||||
end
|
||||
|
||||
json.views article.views
|
||||
|
||||
if article.author.present?
|
||||
|
||||
@@ -8,7 +8,7 @@ json.account_id article.account_id
|
||||
|
||||
if article.portal.present?
|
||||
json.portal do
|
||||
json.partial! 'api/v1/accounts/portals/portal', formats: [:json], portal: article.portal
|
||||
json.partial! 'api/v1/accounts/portals/portal', formats: [:json], portal: article.portal, articles: []
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -3,10 +3,11 @@ json.payload do
|
||||
end
|
||||
|
||||
json.meta do
|
||||
json.current_page @current_page
|
||||
json.articles_count @articles_count
|
||||
json.all_articles_count @portal_articles.size
|
||||
json.archived_articles_count @articles.archived.size
|
||||
json.articles_count @articles_count
|
||||
json.current_page @current_page
|
||||
json.draft_articles_count @all_articles.draft.size
|
||||
json.mine_articles_count @all_articles.search_by_author(current_user.id).size if current_user.present?
|
||||
json.published_count @articles.published.size
|
||||
json.draft_articles_count @articles.draft.size
|
||||
json.mine_articles_count @articles.search_by_author(current_user.id).size if current_user.present?
|
||||
end
|
||||
|
||||
@@ -27,5 +27,5 @@ if category.root_category.present?
|
||||
end
|
||||
|
||||
json.meta do
|
||||
json.articles_count category.articles.size
|
||||
json.articles_count category.articles.search(locale: @current_locale).size
|
||||
end
|
||||
|
||||
@@ -28,11 +28,11 @@ json.portal_members do
|
||||
end
|
||||
|
||||
json.meta do
|
||||
json.all_articles_count portal.articles.size
|
||||
json.archived_articles_count portal.articles.archived.size
|
||||
json.published_count portal.articles.published.size
|
||||
json.draft_articles_count portal.articles.draft.size
|
||||
json.mine_articles_count portal.articles.search_by_author(current_user.id).size if current_user.present?
|
||||
json.categories_count portal.categories.size
|
||||
json.all_articles_count articles.try(:size)
|
||||
json.archived_articles_count articles.try(:archived).try(:size)
|
||||
json.published_count articles.try(:published).try(:size)
|
||||
json.draft_articles_count articles.try(:draft).try(:size)
|
||||
json.mine_articles_count articles.search_by_author(current_user.id).try(:size) if current_user.present? && articles.any?
|
||||
json.categories_count portal.categories.try(:size)
|
||||
json.default_locale portal.default_locale
|
||||
end
|
||||
|
||||
@@ -1 +1 @@
|
||||
json.partial! 'portal', portal: @portal
|
||||
json.partial! 'portal', portal: @portal, articles: []
|
||||
|
||||
@@ -1 +1 @@
|
||||
json.partial! 'portal', portal: @portal
|
||||
json.partial! 'portal', portal: @portal, articles: []
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
json.payload do
|
||||
json.array! @portals, partial: 'portal', as: :portal
|
||||
json.array! @portals.each do |portal|
|
||||
json.partial! 'portal', formats: [:json], portal: portal, articles: []
|
||||
end
|
||||
end
|
||||
|
||||
json.meta do
|
||||
|
||||
@@ -1 +1 @@
|
||||
json.partial! 'portal', portal: @portal
|
||||
json.partial! 'portal', portal: @portal, articles: @articles
|
||||
|
||||
@@ -1 +1 @@
|
||||
json.partial! 'portal', portal: @portal
|
||||
json.partial! 'portal', portal: @portal, articles: []
|
||||
|
||||
Reference in New Issue
Block a user