1
- use std:: { collections:: BTreeMap , sync:: Arc } ;
1
+ use std:: { collections:: BTreeMap , sync:: Arc , time :: UNIX_EPOCH } ;
2
2
3
3
use anyhow:: Context ;
4
4
use candid:: Principal ;
5
- use chrono:: { DateTime , Utc } ;
5
+ use chrono:: { DateTime , NaiveDateTime , Utc } ;
6
6
use futures:: { future, stream, StreamExt , TryStreamExt } ;
7
7
use serde:: { Deserialize , Serialize } ;
8
8
use yral_canisters_client:: individual_user_template:: {
9
- GetPostsOfUserProfileError , IndividualUserTemplate , PostDetailsForFrontend , SystemTime ,
9
+ GetPostsOfUserProfileError , IndividualUserTemplate , PostDetailsForFrontend ,
10
10
} ;
11
11
12
12
use super :: {
@@ -20,7 +20,7 @@ pub(crate) struct Item {
20
20
pub ( crate ) publisher_user_id : String ,
21
21
pub ( crate ) post_id : u64 ,
22
22
pub ( crate ) canister_id : Principal ,
23
- pub ( crate ) timestamp : SystemTime ,
23
+ pub ( crate ) timestamp : String ,
24
24
pub ( crate ) is_nsfw : IsNsfw , // TODO: extra metadata
25
25
}
26
26
@@ -58,6 +58,12 @@ async fn load_all_posts(
58
58
Ok ( posts)
59
59
}
60
60
61
+ fn nanos_to_rfc3339 ( secs : i64 , subsec_nanos : u32 ) -> String {
62
+ let time = DateTime :: from_timestamp ( secs, subsec_nanos) . unwrap ( ) ;
63
+
64
+ time. to_rfc3339 ( )
65
+ }
66
+
61
67
pub ( crate ) async fn load_items < ' a > (
62
68
admin : Arc < AdminCanisters > ,
63
69
low_pass : DateTime < Utc > ,
@@ -124,7 +130,10 @@ pub(crate) async fn load_items<'a>(
124
130
. try_flatten_unordered ( None )
125
131
. map ( |post| {
126
132
post. map ( |( canister, is_nsfw, post) | Item {
127
- timestamp : post. created_at ,
133
+ timestamp : nanos_to_rfc3339 (
134
+ post. created_at . secs_since_epoch as i64 ,
135
+ post. created_at . nanos_since_epoch ,
136
+ ) ,
128
137
video_id : post. video_uid ,
129
138
publisher_user_id : post. created_by_user_principal_id . to_text ( ) ,
130
139
canister_id : canister,
0 commit comments