From ce85caf7817ef0e07cd4f46e39a769aee07cbda4 Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Mon, 15 Jul 2013 00:45:06 -0400 Subject: [PATCH] changed counter --- app.rb | 4 ++-- migrations/016_site_updated_count.rb | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 migrations/016_site_updated_count.rb diff --git a/app.rb b/app.rb index 21dc6590..6175a3f6 100644 --- a/app.rb +++ b/app.rb @@ -279,7 +279,7 @@ post '/site_files/upload' do current_site.update site_changed: true end - current_site.update updated_at: Time.now + current_site.update changed_count: 1+current_site.changed_count, updated_at: Time.now flash[:success] = "Successfully uploaded file #{sanitized_filename}." redirect '/dashboard' @@ -349,7 +349,7 @@ post '/site_files/save/:filename' do |filename| current_site.update site_changed: true end - current_site.update updated_at: Time.now + current_site.update changed_count: 1+current_site.changed_count, updated_at: Time.now 'ok' end diff --git a/migrations/016_site_updated_count.rb b/migrations/016_site_updated_count.rb new file mode 100644 index 00000000..4ba7c0bb --- /dev/null +++ b/migrations/016_site_updated_count.rb @@ -0,0 +1,11 @@ +Sequel.migration do + up { + DB.add_column :sites, :changed_count, :integer, default: 0 + DB.add_index :sites, :changed_count + } + + down { + DB.drop_column :sites, :changed_count + DB.drop_index :sites, :changed_count + } +end \ No newline at end of file