Class: SakaiInfo::SiteProperty

Inherits:
Object
  • Object
show all
Defined in:
lib/sakai-info/site.rb

Class Method Summary collapse

Class Method Details

.find_by_site_id(site_id) ⇒ Object



403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
# File 'lib/sakai-info/site.rb', line 403

def self.find_by_site_id(site_id)
  properties = {}
  # HACK: reading blobs via OCI8 is really slow, make the db server do it!
  #  This is multiple orders of magnitude faster.
  #  But, this will break if the property value is > 4000chars and may not work
  #  on mysql, so here's the original version:
  # DB.connect[:sakai_site_property].where(:site_id => site_id).all.each do |row|
  #   properties[row[:name]] = row[:value].read
  # end
  DB.connect[:sakai_site_property].
    select(:name, :to_char.sql_function(:value).as(:value)).
    where(:site_id => site_id).all.each do |row|
    properties[row[:name]] = row[:value]
  end
  return properties
end

.find_site_ids_by_property(name, value) ⇒ Object



420
421
422
423
424
# File 'lib/sakai-info/site.rb', line 420

def self.find_site_ids_by_property(name, value)
  DB.connect[:sakai_site_property].
    where(:name => name, :to_char.sql_function(:value) => value).
    all.collect{|r| r[:site_id]}
end

.get(site_id, property_name) ⇒ Object



393
394
395
396
397
398
399
400
401
# File 'lib/sakai-info/site.rb', line 393

def self.get(site_id, property_name)
  row = DB.connect[:sakai_site_property].
    where(:site_id => site_id, :name => property_name).first
  if row.nil?
    nil
  else
    row[:value].read
  end
end