diff options
author | tom barrett <spalf0@gmail.com> | 2019-04-02 04:53:54 -0500 |
---|---|---|
committer | tom barrett <spalf0@gmail.com> | 2019-04-02 04:53:54 -0500 |
commit | 9e1cc5ab923492570a84ac35fe573d22c051f86b (patch) | |
tree | 8a4371560b0051920aef2c74f0d91636377b147f /src/bin | |
parent | 810c77ba30c65215c2d5e4b6f8a73f3b73e2b152 (diff) |
added last_modified to database entry
Diffstat (limited to 'src/bin')
-rw-r--r-- | src/bin/server.rs | 5 |
1 files changed, 3 insertions, 2 deletions
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<String, Mass> { fn backup(masses: HashMap<String, Mass>) { 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) |