Update user revision date with sends

pull/1530/head
Daniel García 4 years ago
parent 551810c486
commit 46a1a013cd
No known key found for this signature in database
GPG Key ID: FC8A7D14C3CD543A

@ -157,7 +157,7 @@ use crate::error::MapResult;
impl Send { impl Send {
pub fn save(&mut self, conn: &DbConn) -> EmptyResult { pub fn save(&mut self, conn: &DbConn) -> EmptyResult {
// self.update_users_revision(conn); self.update_users_revision(conn);
self.revision_date = Utc::now().naive_utc(); self.revision_date = Utc::now().naive_utc();
db_run! { conn: db_run! { conn:
@ -192,7 +192,7 @@ impl Send {
} }
pub fn delete(&self, conn: &DbConn) -> EmptyResult { pub fn delete(&self, conn: &DbConn) -> EmptyResult {
// self.update_users_revision(conn); self.update_users_revision(conn);
db_run! { conn: { db_run! { conn: {
diesel::delete(sends::table.filter(sends::uuid.eq(&self.uuid))) diesel::delete(sends::table.filter(sends::uuid.eq(&self.uuid)))
@ -201,6 +201,17 @@ impl Send {
}} }}
} }
pub fn update_users_revision(&self, conn: &DbConn) {
match self.user_uuid {
Some(user_uuid) => {
User::update_uuid_revision(&user_uuid, conn);
}
None => {
// Belongs to Organization, not implemented
}
}
}
pub fn delete_all_by_user(user_uuid: &str, conn: &DbConn) -> EmptyResult { pub fn delete_all_by_user(user_uuid: &str, conn: &DbConn) -> EmptyResult {
for send in Self::find_by_user(user_uuid, &conn) { for send in Self::find_by_user(user_uuid, &conn) {
send.delete(&conn)?; send.delete(&conn)?;

Loading…
Cancel
Save