Add created timestamps for tags
This commit is contained in:
@@ -3,6 +3,7 @@ extern crate diesel;
|
||||
extern crate rayon;
|
||||
|
||||
use actix_web_prom::PrometheusMetrics;
|
||||
use chrono::Utc;
|
||||
use futures::stream::StreamExt;
|
||||
use lazy_static::lazy_static;
|
||||
use prometheus::{self, IntGauge};
|
||||
@@ -310,7 +311,10 @@ async fn add_tag(_: Claims, body: web::Json<AddTagRequest>) -> impl Responder {
|
||||
Ok(t.id)
|
||||
} else {
|
||||
match diesel::insert_into(tags::table)
|
||||
.values(InsertTag { name: tag.clone() })
|
||||
.values(InsertTag {
|
||||
name: tag.clone(),
|
||||
created_time: Utc::now().timestamp(),
|
||||
})
|
||||
.execute(connection)
|
||||
.and_then(|_| {
|
||||
no_arg_sql_function!(
|
||||
@@ -347,6 +351,7 @@ async fn add_tag(_: Claims, body: web::Json<AddTagRequest>) -> impl Responder {
|
||||
.values(InsertTaggedPhoto {
|
||||
tag_id,
|
||||
photo_name: file_name.clone(),
|
||||
created_time: Utc::now().timestamp(),
|
||||
})
|
||||
.execute(connection)
|
||||
.map(|_| {
|
||||
@@ -384,7 +389,7 @@ async fn get_tags(_: Claims, request: web::Query<ThumbnailRequest>) -> impl Resp
|
||||
match tags::table
|
||||
.left_join(tagged_photo::table)
|
||||
.filter(tagged_photo::photo_name.eq(&request.path))
|
||||
.select((tags::id, tags::name))
|
||||
.select((tags::id, tags::name, tags::created_time))
|
||||
.get_results::<Tag>(&connect())
|
||||
{
|
||||
Ok(tags) => HttpResponse::Ok().json(tags),
|
||||
|
||||
Reference in New Issue
Block a user