Skip to content

Commit

Permalink
Merge pull request #1279 from openjournals/editor-status
Browse files Browse the repository at this point in the history
Adding editor status to JSON response
  • Loading branch information
arfon authored Sep 27, 2023
2 parents 9ea4acb + 87a6224 commit 7e80c06
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/models/editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ def category_list
categories.join(", ")
end

def status
if retired?
"Retired"
else
"Active"
end
end

def three_month_average
paper_count = self.papers.visible.since(3.months.ago).count
return sprintf("%.1f", paper_count / 3.0)
Expand Down
1 change: 1 addition & 0 deletions app/views/papers/show.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ if @paper.published?
json.authors @paper.metadata_authors
json.submitting_author @paper&.submitting_author&.pretty_github_username
json.editor @paper.metadata_editor
json.editor_status @paper&.editor&.status
if @paper.editor
json.editor_name @paper.editor.full_name
json.editor_url @paper.editor.url if @paper.editor.url
Expand Down
1 change: 1 addition & 0 deletions spec/controllers/papers_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@
expect(parsed_response["state"]).to eq("accepted")
expect(parsed_response["software_repository"]).to eq("http://github.com/arfon/fidgit")
expect(parsed_response["editor"]).to eq("@arfon")
expect(parsed_response["editor_status"]).to eq("Active")
expect(parsed_response["submitting_author"]).to eq("@foobar")
expect(parsed_response["editor_name"]).to eq("Person McEditor")
expect(parsed_response["editor_orcid"]).to eq("0000-0000-0000-1234")
Expand Down

0 comments on commit 7e80c06

Please sign in to comment.