Skip to content

Commit 5db12b8

Browse files
committed
Expose rated_at timestamp in API
1 parent 545cb29 commit 5db12b8

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

lib/plexus_web/controllers/api/v1/rating_json.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ defmodule PlexusWeb.API.V1.RatingJSON do
2626
installation_source: rating.installation_source,
2727
score: %{numerator: rating.score, denominator: 4},
2828
notes: rating.notes,
29-
rating_type: rating.rating_type
29+
rating_type: rating.rating_type,
30+
rated_at: rating.inserted_at
3031
}
3132
end
3233
end

lib/plexus_web/controllers/api/v1/schemas/rating.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ defmodule PlexusWeb.API.V1.Schemas.Rating do
1818
installation_source: %Schema{type: :string, description: "Installation Source"},
1919
score: Score,
2020
notes: %Schema{type: :string, description: "Notes", nullable: true},
21-
rating_type: %Schema{type: :string, description: "Rating Type", enum: ["micro_g", "native"]}
21+
rating_type: %Schema{type: :string, description: "Rating Type", enum: ["micro_g", "native"]},
22+
rated_at: %Schema{type: :string, description: "Rated at timestamp", format: :"date-time"}
2223
},
2324
example: %{
2425
"id" => "72f5d88e-a467-4729-998f-db1edcfad6bc",
@@ -31,7 +32,8 @@ defmodule PlexusWeb.API.V1.Schemas.Rating do
3132
"installation_source" => "google_play_alternative",
3233
"notes" => nil,
3334
"rom_build" => "2024083100",
34-
"rom_name" => "GrapheneOS"
35+
"rom_name" => "GrapheneOS",
36+
"rated_at" => "2025-05-19T23:02:29.837724Z"
3537
}
3638
})
3739
end

test/plexus_web/controllers/api/v1/rating_controller_test.exs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ defmodule PlexusWeb.API.V1.RatingControllerTest do
5757
attrs = Map.put(@create_attrs, :app_package, app_package)
5858

5959
conn = post(conn, ~p"/api/v1/apps/#{app_package}/ratings", rating: attrs)
60-
assert %{"id" => id} = json_response(conn, 201)["data"]
60+
assert %{"id" => id, "rated_at" => rated_at} = json_response(conn, 201)["data"]
6161

6262
conn = get(conn, ~p"/api/v1/apps/#{app_package}/ratings/#{id}")
6363

@@ -72,7 +72,8 @@ defmodule PlexusWeb.API.V1.RatingControllerTest do
7272
"installation_source" => "fdroid",
7373
"rating_type" => "native",
7474
"notes" => "some notes",
75-
"score" => %{"numerator" => 2, "denominator" => 4}
75+
"score" => %{"numerator" => 2, "denominator" => 4},
76+
"rated_at" => ^rated_at
7677
} = json_response(conn, 200)["data"]
7778
end
7879

0 commit comments

Comments
 (0)