Changeset 1613
- Timestamp:
- 06/10/08 11:42:56 (7 months ago)
- Files:
-
- hive/trunk/data_webapp/app/controllers/hc_database_controller.rb (modified) (3 diffs)
- hive/trunk/data_webapp/app/controllers/queue_urls_controller.rb (modified) (3 diffs)
- hive/trunk/data_webapp/app/views/queue_urls/new.html.erb (modified) (1 diff)
- hive/trunk/data_webapp/public/javascripts/application.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
hive/trunk/data_webapp/app/controllers/hc_database_controller.rb
r1608 r1613 43 43 # Create a JobSource 44 44 job_source = new_or_existing(JobSource,obj_hash.delete(:source).symbolize_keys) 45 job_source.save!46 45 47 46 # Extract the set of URLs … … 52 51 job = DroneJob.new(obj_hash.symbolize_keys) 53 52 job.job_source = job_source 54 job.save!55 53 56 54 # Create the QueueUrl objects … … 58 56 insert_pending_url(:url => url, :priority => priority, :job => job) 59 57 end 60 61 return job.id 58 =begin 59 if job.pending_urls_count > 0 or job.completed_urls_count > 0 60 job_source.save! 61 job.save! 62 end 63 =end 64 return job.id.nil? ? 0 : job.id 62 65 end 63 66 64 67 def insert_pending_url(args) 68 return if args[:url].to_s.empty? 65 69 PendingUrl.transaction do 70 71 url_obj = nil 66 72 # There's a small chance that another process instance may have simultaneously inserted 67 73 # the same URL into our queue. In that case, we simply retry the insert operation until it succeeds. 68 url_obj = nil69 74 while true 70 75 begin hive/trunk/data_webapp/app/controllers/queue_urls_controller.rb
r1609 r1613 48 48 :name => 'drone_interface', 49 49 }, 50 :notify_source => (params[:notify]),50 :notify_source => params[:notify], 51 51 :queue_urls => { 52 52 params[:queue_url][:url] => params[:queue_url][:priority] … … 62 62 job_id = c.insert_drone_job(job_hash) 63 63 # Get the inserted job 64 job = DroneJob.find(job_id) 64 job = job_id > 0 ? DroneJob.find(job_id) : nil 65 65 66 @queue_url = [] 66 67 if not job.nil? … … 74 75 format.xml { render :xml => @queue_url, :status => :created, :location => @queue_url } 75 76 else 76 flash[:notice] = 'Failed to create QueueUrl .'77 flash[:notice] = 'Failed to create a job for your request.<br>Perhaps an invalid url?' 77 78 format.html { redirect_to :action => "new" } 78 79 format.xml { render :xml => @queue_url.errors, :status => :unprocessable_entity } hive/trunk/data_webapp/app/views/queue_urls/new.html.erb
r1501 r1613 5 5 <%= f.text_field :url %> 6 6 <%= f.select "priority",{"high" => 500, "medium" => 100, "low" => 1}.sort{|a,b| a[1] <=> b[1]} %> 7 <%= f.submit "Create" %> 7 <%= f.submit "Create" %><br> 8 Notify? : <%= check_box_tag 'notify','false',false,{:onchange => "toggleEnabledById('address'); this.value = (this.value == 'true' ? 'false' : 'true')"} %> 9 Email Address : <%= text_field_tag 'address','',:disabled => true %> 8 10 <% end %> 9 11 <p/> hive/trunk/data_webapp/public/javascripts/application.js
r1501 r1613 69 69 } 70 70 } 71 72 function toggleEnabledById(elt_id) { 73 if(elt = document.getElementById(elt_id)) { 74 if(elt.disabled == true) { 75 elt.disabled = false; 76 } 77 else { 78 elt.disabled = true; 79 } 80 } 81 }
