fix: Update article count in portal admin dashboard (#5647)

Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
Tejaswini Chile
2022-10-22 02:13:15 +05:30
committed by GitHub
parent 95cc55d043
commit 782165478b
29 changed files with 157 additions and 94 deletions

View File

@@ -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?

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -1 +1 @@
json.partial! 'portal', portal: @portal
json.partial! 'portal', portal: @portal, articles: []

View File

@@ -1 +1 @@
json.partial! 'portal', portal: @portal
json.partial! 'portal', portal: @portal, articles: []

View File

@@ -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

View File

@@ -1 +1 @@
json.partial! 'portal', portal: @portal
json.partial! 'portal', portal: @portal, articles: @articles

View File

@@ -1 +1 @@
json.partial! 'portal', portal: @portal
json.partial! 'portal', portal: @portal, articles: []