-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WJ-1283] Change time serialization format #2128
Conversation
cb9d1d2
to
75fe3fc
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2128 +/- ##
==========================================
+ Coverage 1.89% 1.92% +0.03%
==========================================
Files 137 140 +3
Lines 5600 5766 +166
==========================================
+ Hits 106 111 +5
- Misses 5494 5655 +161
|
841ab5c
to
cc0a6ae
Compare
The view structs using the {
...
"data": {
"site": {
"site_id": 1,
"created_at": "2024-10-08 03:49:45.082887 +00:00:00",
"updated_at": null,
"deleted_at": null,
...
},
...
"page": {
"page_id": 16,
"created_at": "2024-10-08 03:49:45.082887 +00:00:00",
"updated_at": "2024-10-08 03:59:08.397184 +00:00:00",
"deleted_at": null,
... The pub struct GetDeletedPageOutput {
pub page_id: i64,
#[serde(with = "time::serde::rfc3339")]
pub page_created_at: OffsetDateTime,
pub page_updated_at: Option<OffsetDateTime>,
#[serde(with = "time::serde::rfc3339")]
pub page_deleted_at: OffsetDateTime, [{
"page_id": 16,
"page_created_at": "2024-10-08T03:49:45.082887Z",
"page_updated_at": "2024-10-08 03:59:08.397184 +00:00:00",
"page_deleted_at": "2024-10-08T04:03:46.039123Z",
"page_revision_count": 5,
"site_id": 1,
"discussion_thread_id": null,
"hidden_fields": [],
"title": "Welcome to your new Wikijump instance!",
"alt_title": "",
"slug": "start",
"tags": [],
"rating": 49
}] |
I added the serialization flags for nullable fields, but I see that the issue with the view service (and why the changes weren't added) is because the timestamps are in the SeaORM entity files. I'll see if I can alter the struct generation for those. |
I've added the attribute manually to all the fields, since it doesn't seem we can automatically add the attribute to time fields using |
By emitting RFC-3339 format datetimes, we can more easily interpret the information in JS with only
Date.parse()
instead of needing custom date processing functions. This requires a#[serde(with)]
annotation onOffsetDateTime
fields.Example of output from
page_get
:In order to help test this, I added a new
info
API method which consolidates some of the various information methods we had before. This produces a JSON object with the fields instead of returning it as unstructured text.Example of info response: