fix: Add all articles count to article API (#5497)

This commit is contained in:
Tejaswini Chile
2022-09-28 01:05:53 +05:30
committed by GitHub
parent c1c57fb2cd
commit 336c09e072
2 changed files with 7 additions and 0 deletions

View File

@@ -5,4 +5,9 @@ end
json.meta do
json.current_page @current_page
json.articles_count @articles_count
json.all_articles_count @articles_count
json.archived_articles_count @articles.archived.size
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

@@ -195,6 +195,8 @@ RSpec.describe 'Api::V1::Accounts::Articles', type: :request do
json_response = JSON.parse(response.body)
expect(json_response['payload'].count).to be 1
expect(json_response['meta']['articles_count']).to be 2
expect(json_response['meta']['all_articles_count']).to be 2
expect(json_response['meta']['mine_articles_count']).to be 1
end
end