Class: SfxDb::SfxDbBase

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/sfx_db/sfx_db_base.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.fetch_sfx_urlsObject

Atttempts to extract all URLs that SFX knows about from the db. This process is not 100%, becuase of the way SFX calculates URLs on the fly. We are only grabbing them from the db–and even the way they are stored in the db is hard for us to grab reliably! So this is really just a kind of guess heuristic in a bunch of ways. But we do our best, and use this to load the SfxUrl model.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/models/sfx_db/sfx_db_base.rb', line 33

def self.fetch_sfx_urls
    # Fetch all target services that look like they might have a URL
    # in the parse param, and that are active. We know this misses ones
    # that are just active for certain institutes! Known defect.
    target_services = TargetService.find(:all, :conditions => "PARSE_PARAM like '%.%' and AVAILABILITY ='ACTIVE'")

    # Same with object portfolios, which can also have urls hidden in em
    object_portfolios = ObjectPortfolio.find(:all, :conditions => "PARSE_PARAM like '%.%' and AVAILABILITY = 'ACTIVE'")

    urls = []
    (target_services + object_portfolios).each do |db_row|
      parse_param = db_row.PARSE_PARAM

      # Try to get things that look sort of like URLs out. Brutal force,
      # sorry. 
      url_re = Regexp.new('(https?://\S+\.\S+)(\s|$)')
      urls.concat( parse_param.scan( url_re ).collect {|matches| matches[0]} )
      
    end
    urls.uniq!
    return urls        
end

Instance Method Details

#readonly?Boolean

All SfxDb things are read-only!

Returns:

  • (Boolean)


18
19
20
# File 'app/models/sfx_db/sfx_db_base.rb', line 18

def readonly?() 
  return true
end