mirror of
https://github.com/discourse/discourse.git
synced 2025-01-30 22:56:07 +08:00
Merge pull request #1707 from chancancode/as_json_fix
The Rails JSON encoder API requires `as_json` to take an optional arg
This commit is contained in:
commit
f5d905c215
|
@ -61,7 +61,7 @@ class AdminDashboardData
|
||||||
AdminDashboardData.new.problems
|
AdminDashboardData.new.problems
|
||||||
end
|
end
|
||||||
|
|
||||||
def as_json
|
def as_json(options = nil)
|
||||||
@json ||= {
|
@json ||= {
|
||||||
reports: REPORTS.map { |type| Report.find(type).as_json },
|
reports: REPORTS.map { |type| Report.find(type).as_json },
|
||||||
admins: User.admins.count,
|
admins: User.admins.count,
|
||||||
|
|
|
@ -8,7 +8,7 @@ class IncomingLinksReport
|
||||||
@data = nil
|
@data = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def as_json
|
def as_json(options = nil)
|
||||||
{
|
{
|
||||||
type: self.type,
|
type: self.type,
|
||||||
title: I18n.t("reports.#{self.type}.title"),
|
title: I18n.t("reports.#{self.type}.title"),
|
||||||
|
|
|
@ -11,7 +11,7 @@ class Report
|
||||||
@prev30Days = nil
|
@prev30Days = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def as_json
|
def as_json(options = nil)
|
||||||
{
|
{
|
||||||
type: self.type,
|
type: self.type,
|
||||||
title: I18n.t("reports.#{self.type}.title"),
|
title: I18n.t("reports.#{self.type}.title"),
|
||||||
|
|
|
@ -15,7 +15,7 @@ class Search
|
||||||
return topic_results.result_ids
|
return topic_results.result_ids
|
||||||
end
|
end
|
||||||
|
|
||||||
def as_json
|
def as_json(options = nil)
|
||||||
@by_type.values.map do |grouped_result|
|
@by_type.values.map do |grouped_result|
|
||||||
grouped_result.as_json
|
grouped_result.as_json
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,7 +15,7 @@ class Search
|
||||||
@url, @id, @title = row[:url], row[:id], row[:title]
|
@url, @id, @title = row[:url], row[:id], row[:title]
|
||||||
end
|
end
|
||||||
|
|
||||||
def as_json
|
def as_json(options = nil)
|
||||||
json = {id: @id, title: @title, url: @url}
|
json = {id: @id, title: @title, url: @url}
|
||||||
json[:avatar_template] = @avatar_template if @avatar_template.present?
|
json[:avatar_template] = @avatar_template if @avatar_template.present?
|
||||||
json[:color] = @color if @color.present?
|
json[:color] = @color if @color.present?
|
||||||
|
|
|
@ -20,7 +20,7 @@ class Search
|
||||||
@result_ids << result.id
|
@result_ids << result.id
|
||||||
end
|
end
|
||||||
|
|
||||||
def as_json
|
def as_json(options = nil)
|
||||||
{ type: @type.to_s,
|
{ type: @type.to_s,
|
||||||
name: I18n.t("search.types.#{@type.to_s}"),
|
name: I18n.t("search.types.#{@type.to_s}"),
|
||||||
more: @more,
|
more: @more,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user