-
-
Notifications
You must be signed in to change notification settings - Fork 159
Expand file tree
/
Copy pathrating_json.ex
More file actions
33 lines (29 loc) · 834 Bytes
/
rating_json.ex
File metadata and controls
33 lines (29 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
defmodule PlexusWeb.API.V1.RatingJSON do
use PlexusWeb, :json
alias Plexus.Schemas.Rating
def index(%{page: page}) do
%{
data: for(rating <- page.entries, do: data(rating)),
meta: meta(page)
}
end
def show(%{rating: rating}) do
%{data: data(rating)}
end
defp data(%Rating{} = rating) do
%{
id: rating.id,
android_version: rating.android_version,
app_package: rating.app_package,
app_version: rating.app_version || "",
app_build_number: rating.app_build_number,
rom_name: rating.rom_name,
rom_build: rating.rom_build,
installation_source: rating.installation_source,
score: %{numerator: rating.score, denominator: 4},
notes: rating.notes,
rating_type: rating.rating_type,
rated_at: rating.inserted_at
}
end
end