myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [1888] trunk: Downloads and viewings now store us


From: noreply
Subject: [myexperiment-hackers] [1888] trunk: Downloads and viewings now store user-agent for packs, files and workflows.
Date: Mon, 27 Oct 2008 11:20:42 -0400 (EDT)

Revision
1888
Author
alekses6
Date
2008-10-27 11:20:42 -0400 (Mon, 27 Oct 2008)

Log Message

Downloads and viewings now store user-agent for packs, files and workflows.

Modified Paths

Added Paths

Diff

Modified: trunk/app/controllers/blobs_controller.rb (1887 => 1888)


--- trunk/app/controllers/blobs_controller.rb	2008-10-27 13:50:15 UTC (rev 1887)
+++ trunk/app/controllers/blobs_controller.rb	2008-10-27 15:20:42 UTC (rev 1888)
@@ -38,7 +38,7 @@
   # GET /files/1;download
   def download
     if allow_statistics_logging
-      @download = Download.create(:contribution => @blob.contribution, :user => (logged_in? ? current_user : nil))
+      @download = Download.create(:contribution => @blob.contribution, :user => (logged_in? ? current_user : nil), :user_agent => request.env['HTTP_USER_AGENT'])
     end
     
     send_data(@blob.content_blob.data, :filename => @blob.local_name, :type => @blob.content_type)
@@ -74,7 +74,7 @@
   # GET /files/1
   def show
     if allow_statistics_logging
-      @viewing = Viewing.create(:contribution => @blob.contribution, :user => (logged_in? ? current_user : nil))
+      @viewing = Viewing.create(:contribution => @blob.contribution, :user => (logged_in? ? current_user : nil), :user_agent => request.env['HTTP_USER_AGENT'])
     end
     
     respond_to do |format|

Modified: trunk/app/controllers/packs_controller.rb (1887 => 1888)


--- trunk/app/controllers/packs_controller.rb	2008-10-27 13:50:15 UTC (rev 1887)
+++ trunk/app/controllers/packs_controller.rb	2008-10-27 15:20:42 UTC (rev 1888)
@@ -49,7 +49,7 @@
   # GET /packs/1
   def show
     if allow_statistics_logging
-      @viewing = Viewing.create(:contribution => @pack.contribution, :user => (logged_in? ? current_user : nil))
+      @viewing = Viewing.create(:contribution => @pack.contribution, :user => (logged_in? ? current_user : nil), :user_agent => request.env['HTTP_USER_AGENT'])
     end
     
     respond_to do |format|
@@ -76,7 +76,7 @@
     @pack.create_zip(current_user, image_hash)
     
     if allow_statistics_logging
-      @download = Download.create(:contribution => @pack.contribution, :user => (logged_in? ? current_user : nil))
+      @download = Download.create(:contribution => @pack.contribution, :user => (logged_in? ? current_user : nil), :user_agent => request.env['HTTP_USER_AGENT'])
     end
     
     send_file @pack.archive_file_path, :disposition => 'attachment'

Modified: trunk/app/controllers/workflows_controller.rb (1887 => 1888)


--- trunk/app/controllers/workflows_controller.rb	2008-10-27 13:50:15 UTC (rev 1887)
+++ trunk/app/controllers/workflows_controller.rb	2008-10-27 15:20:42 UTC (rev 1888)
@@ -158,7 +158,7 @@
   # GET /workflows/1;download
   def download
     if allow_statistics_logging
-      @download = Download.create(:contribution => @workflow.contribution, :user => (logged_in? ? current_user : nil))
+      @download = Download.create(:contribution => @workflow.contribution, :user => (logged_in? ? current_user : nil), :user_agent => request.env['HTTP_USER_AGENT'])
     end
     
     send_data(@viewing_version.content_blob.data, :filename => @workflow.filename(@viewing_version_number), :type => @workflow.content_type)
@@ -228,7 +228,7 @@
   # GET /workflows/1
   def show
     if allow_statistics_logging
-      @viewing = Viewing.create(:contribution => @workflow.contribution, :user => (logged_in? ? current_user : nil))
+      @viewing = Viewing.create(:contribution => @workflow.contribution, :user => (logged_in? ? current_user : nil), :user_agent => request.env['HTTP_USER_AGENT'])
     end
 
     respond_to do |format|

Added: trunk/db/migrate/069_add_user_agent_to_viewings_and_downloads.rb (0 => 1888)


--- trunk/db/migrate/069_add_user_agent_to_viewings_and_downloads.rb	                        (rev 0)
+++ trunk/db/migrate/069_add_user_agent_to_viewings_and_downloads.rb	2008-10-27 15:20:42 UTC (rev 1888)
@@ -0,0 +1,18 @@
+class AddUserAgentToViewingsAndDownloads < ActiveRecord::Migration
+  
+  # user-agent will now be stored with "viewing" and "download" entries,
+  # where initial check showed that the current user-agent is not a bot
+  #
+  # for viewings/downloads made by bots, no entries in viewings/downloads
+  # tables are created
+  
+  def self.up
+    add_column :viewings, :user_agent, :string, :default => nil
+    add_column :downloads, :user_agent, :string, :default => nil
+  end
+
+  def self.down
+    remove_column :viewings, :user_agent
+    remove_column :downloads, :user_agent
+  end
+end

reply via email to

[Prev in Thread] Current Thread [Next in Thread]