From 9e1cc5ab923492570a84ac35fe573d22c051f86b Mon Sep 17 00:00:00 2001 From: tom barrett Date: Tue, 2 Apr 2019 04:53:54 -0500 Subject: added last_modified to database entry --- src/bin/server.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/bin') diff --git a/src/bin/server.rs b/src/bin/server.rs index 708cd3e..9ea1f0d 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -7,7 +7,7 @@ use std::collections::HashMap; use std::io::Write; use std::net::TcpListener; use std::thread::{sleep, spawn}; -use std::time::{Duration, Instant}; +use std::time::{Duration, Instant, SystemTime}; use space::constants; use space::mass::{Mass, MassEntry}; @@ -28,8 +28,9 @@ fn populate() -> HashMap { fn backup(masses: HashMap) { let connection = PgConnection::establish(&get_db_url()).expect("Cannot connect"); + let timestamp = SystemTime::now(); for (name, mass) in masses { - let mass_entry = mass.to_mass_entry(name.to_string()); + let mass_entry = mass.to_mass_entry(name.to_string(), timestamp); diesel::insert_into(db_masses) .values(&mass_entry) .on_conflict(name_column) -- cgit v1.2.3