Add article and comment count to instance API (#15794)

This commit is contained in:
Alex 2021-12-16 13:05:49 -05:00 committed by GitHub
parent 5c13d9d8fd
commit 51f2bf7aab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View file

@ -5,6 +5,7 @@ module Api
def show
render json: {
comment_count: Comment.estimated_count,
context: ApplicationConfig["FOREM_CONTEXT"],
cover_image_url: Settings::General.main_social_image,
description: Settings::Community.community_description,
@ -12,6 +13,7 @@ module Api
domain: Settings::General.app_domain,
logo_image_url: Settings::General.logo_png,
name: Settings::Community.community_name,
published_article_count: Article.published.estimated_count,
registered_users_count: User.registered.estimated_count,
tagline: Settings::Community.tagline,
version: release_version,

View file

@ -6,6 +6,7 @@ RSpec.describe "Api::V0::Instances", type: :request do
create(:user)
get api_instance_path
expect(response.parsed_body["comment_count"]).to eq Comment.estimated_count
expect(response.parsed_body["context"]).to eq ApplicationConfig["FOREM_CONTEXT"]
expect(response.parsed_body["cover_image_url"]).to eq Settings::General.main_social_image
expect(response.parsed_body["description"]).to eq Settings::Community.community_description
@ -13,6 +14,7 @@ RSpec.describe "Api::V0::Instances", type: :request do
expect(response.parsed_body["domain"]).to eq Settings::General.app_domain
expect(response.parsed_body["logo_image_url"]).to eq Settings::General.logo_png
expect(response.parsed_body["name"]).to eq Settings::Community.community_name
expect(response.parsed_body["published_article_count"]).to eq Article.published.estimated_count
expect(response.parsed_body["registered_users_count"]).to eq User.registered.estimated_count
expect(response.parsed_body["tagline"]).to eq Settings::Community.tagline
expect(response.parsed_body["version"]).to match(/(stable|beta|edge)\.\d{8}\.\d+/)