Reduce the user's trace count when a trace is deleted
authorTom Hughes <tom@compton.nu>
Mon, 1 Oct 2012 16:22:12 +0000 (17:22 +0100)
committerTom Hughes <tom@compton.nu>
Mon, 1 Oct 2012 16:22:12 +0000 (17:22 +0100)
src/postgres.c

index f98f6b2..bfa631a 100644 (file)
@@ -91,6 +91,7 @@ db_destroy_trace(int64_t jobnr)
 {
   STMT("START TRANSACTION");
   INFO("Destroying job %"PRId64"", jobnr);
+  STMT("UPDATE users SET traces_count=traces_count-1 WHERE id=(SELECT user_id FROM gpx_files WHERE id=%"PRId64")", jobnr);
   STMT("DELETE FROM gpx_file_tags WHERE gpx_id=%"PRId64"", jobnr);
   STMT("DELETE FROM gps_points WHERE gpx_id=%"PRId64"", jobnr);
   STMT("DELETE FROM gpx_files WHERE id=%"PRId64"", jobnr);