philomena/lib/philomena_web/forum_json.ex
SomewhatDamaged ae5bfe14e4 Add /forums API Endpoints (#14)
* Adding routes for /forums

Adding routes for new /forums endpoints

* New API Routes

`/forum`
`/forum/:forum_id`

* Add New API Routes

`/forums/:forum_id/topics/:topic_id/`
`/forums/:forum_id/topics/:topic_id/:post_id`

* Adds New API Routes

`/forums/:forum_id/topics`
`/forums/:forum_id/topics/:topic_id`

* Forum JSON formatter

* Updated

Correctly filters out things that should not be shown.

* Added topic JSON filter

* Added correct pagination

* Spacing and neatened

* Cleaned up

Consolidated queries and neatened up spacing.
Fixed name

* Removed unneeded aliases

* Cleaned up

Consolidated queries
Fixed spacing
Removed unneeded aliases

* Cleaned up

Spacing

* Cleaned up

spacing

* Depluralized

* Cleaned up

Removed space

* Removed extra spaces

* Removed extra spaces

* Removed extra spaces

* Removed preloads

* Cleaned up

Grouped clauses

* Consolodated further

* Cleaned up preloads

* Cleaned up

Preloads
consolidated clauses
grouped clauses

* Cleaned up

removed `id`
`locked`

* Removed topic_id

Not useful since the API client should already know it.

* More consolodation of terms

* Add total post count

* Removed unneeded variable

* Last cleanup, I swear.
2020-01-02 17:47:12 -05:00

21 lines
437 B
Elixir

defmodule PhilomenaWeb.ForumJson do
def as_json(%{access_level: "normal"} = forum) do
%{
name: forum.name,
short_name: forum.short_name,
description: forum.description,
topic_count: forum.topic_count,
post_count: forum.post_count
}
end
def as_json(_forum) do
%{
name: nil,
short_name: nil,
description: nil,
topic_count: nil,
post_count: nil
}
end
end