Class: Results

Inherits:
Object
  • Object
show all
Defined in:
app/models/results.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ Results

Returns a new instance of Results.



5
6
7
8
# File 'app/models/results.rb', line 5

def initialize(id)
  @id=id
  @keynames = Array.new
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



4
5
6
# File 'app/models/results.rb', line 4

def id
  @id
end

#keynamesObject

Returns the value of attribute keynames.



4
5
6
# File 'app/models/results.rb', line 4

def keynames
  @keynames
end

Instance Method Details

#get_keyname_listObject



10
11
12
13
14
15
16
17
# File 'app/models/results.rb', line 10

def get_keyname_list
  if @id!=0 then
    keylist=KeywordAttribute.find(:all,:select=>"keyword_attributes.name as kname,count(*) as cnt",:joins=>"JOIN cache_#{@id} ON variable_id=cache_#{@id}.vid",:group=>"keyword_attributes.name",:order=>"cnt DESC")
  else
    keylist=KeywordAttribute.find(:all,:select=>"keyword_attributes.name as kname,count(*) as cnt",:joins=>"JOIN variables ON variable_id=variables.id",:group=>"keyword_attributes.name",:order=>"cnt DESC")
  end
  return keylist
end

#get_keyvalue_list(keyname) ⇒ Object



40
41
42
43
44
45
46
47
# File 'app/models/results.rb', line 40

def get_keyvalue_list(keyname)
  if @id!=0 then
   valuelist=KeywordAttribute.find(:all,:joins=>"JOIN cache_#{@id} ON variable_id=cache_#{@id}.vid",:select=>"value,num_value,count(*) as cnt",:conditions=>["keyword_attributes.name=?",keyname],:group=>"value")
  else
   valuelist=KeywordAttribute.find(:all,:joins=>"JOIN variables ON variable_id=variables.id",:select=>"value,num_value,count(*) as cnt",:conditions=>["keyword_attributes.name=?",keyname],:group=>"value")   
  end
  return valuelist   
end

#get_path_listObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/models/results.rb', line 19

def get_path_list
 if @id!=0 then
   tables="(select v.* from variables v,cache_#{@id} c where v.id=c.vid)"
   path=QueryHistory.find(@id).path
 else
   tables="variables"
   path="/"
 end
     sql1=<<-EOM
      select d2.path as dpath, count(v.id) as cnt
      from directories d1,directories d2,#{tables} v
      where d1.path = ?
        and d2.parent_id = d1.id
        and v.path like #{concat("d2.path","'%'")}
      group by d2.path
      order by cnt DESC
    EOM
    pathlist = Directory.find_by_sql [sql1,path]
  return pathlist
end