added timestamp for feed items
This commit is contained in:
+12
-4
@@ -10,6 +10,7 @@ use crate::{
|
||||
schema::feed_item,
|
||||
};
|
||||
use actix_web::{web, HttpRequest, Responder};
|
||||
use chrono::Local;
|
||||
use diesel::prelude::*;
|
||||
|
||||
use super::structs::article::Article;
|
||||
@@ -41,10 +42,17 @@ pub async fn get(path: web::Path<JsonUser>, req: HttpRequest) -> impl Responder
|
||||
|
||||
let article_list: Vec<Article> = existing_item
|
||||
.into_iter()
|
||||
.map(|feed_item: FeedItem| Article {
|
||||
title: feed_item.title,
|
||||
content: feed_item.content,
|
||||
url: feed_item.url,
|
||||
.map(|feed_item: FeedItem| {
|
||||
let time: String = match feed_item.created_ts {
|
||||
Some(r) => r.to_string(),
|
||||
None => Local::now().naive_local().to_string(),
|
||||
};
|
||||
Article {
|
||||
title: feed_item.title,
|
||||
content: feed_item.content,
|
||||
url: feed_item.url,
|
||||
timestamp: time,
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user