Class: LucidWorks::Datasource

Inherits:
Base
  • Object
show all
Defined in:
lib/lucid_works/datasource.rb,
lib/lucid_works/datasource/job.rb,
lib/lucid_works/datasource/index.rb,
lib/lucid_works/datasource/status.rb,
lib/lucid_works/datasource/history.rb,
lib/lucid_works/datasource/mapping.rb,
lib/lucid_works/datasource/schedule.rb,
lib/lucid_works/datasource/crawldata.rb

Defined Under Namespace

Classes: Crawldata, History, Index, Job, Mapping, Schedule, Status

Constant Summary collapse

BOUNDS =
%w{ tree none }

Constants included from Utils::BoolConverter

Utils::BoolConverter::FALSE_VALUES, Utils::BoolConverter::TRUE_VALUES

Instance Attribute Summary

Attributes inherited from Base

#attributes, #id, #parent, #persisted, #raw_response, #response_data

Instance Method Summary collapse

Methods inherited from Base

all, collection_url, #collection_url, create, #destroy, extract_parent_from_options, find, first, human_attribute_value, #human_attribute_value, #initialize, #inspect, last, member_url, #member_url, #persisted?, #read_attribute_for_validation, #save, schema, singleton_name, to_select, #update_attributes

Methods included from SimpleNaming

#model_name

Methods included from Utils::BoolConverter

#to_bool

Constructor Details

This class inherits a constructor from LucidWorks::Base

Instance Method Details

#commit_within_secObject

Virtual attributes to ease UI implementation



96
97
98
# File 'lib/lucid_works/datasource.rb', line 96

def commit_within_sec
  commit_within.blank? ? nil : commit_within / 1.second.milliseconds
end

#commit_within_sec=(seconds) ⇒ Object



99
100
101
# File 'lib/lucid_works/datasource.rb', line 99

def commit_within_sec=(seconds)
  self.commit_within = seconds.blank? ? nil : seconds.to_i.seconds.milliseconds
end

#delete_after_daysObject



102
103
104
# File 'lib/lucid_works/datasource.rb', line 102

def delete_after_days
  delete_after.blank? ? nil : delete_after / 1.second.milliseconds / 1.day.seconds
end

#delete_after_days=(days) ⇒ Object



105
106
107
# File 'lib/lucid_works/datasource.rb', line 105

def delete_after_days=(days)
  self.delete_after = days.blank? ? nil : days.to_i.days.milliseconds
end

#destroyable?Boolean

Returns:

  • (Boolean)


122
123
124
125
# File 'lib/lucid_works/datasource.rb', line 122

def destroyable?
  # Don't let user destroy data sources of system collections
  !collection.system?
end

#document_countObject



109
110
111
# File 'lib/lucid_works/datasource.rb', line 109

def document_count
  collection.search(:wt => :ruby, :q => (type == 'lucidworkslogs' ? "*:*" : "data_source:#{id}"), :rows => 0)['response']['numFound']
end

#editable?Boolean

Don’t let user edit data sources of system collections

Returns:

  • (Boolean)


118
119
120
# File 'lib/lucid_works/datasource.rb', line 118

def editable?
  !collection.system?
end

#empty!Object



113
114
115
# File 'lib/lucid_works/datasource.rb', line 113

def empty!
  build_index.destroy
end

#progressObject



135
136
137
138
139
140
141
# File 'lib/lucid_works/datasource.rb', line 135

def progress
  return nil if status.stopped?
  return nil unless histories.size > 0
  percent_done = status.elapsed_time.to_f / histories.last.duration
  percent_done = nil if percent_done > 1.0
  percent_done
end

#start_crawl!Object



127
128
129
# File 'lib/lucid_works/datasource.rb', line 127

def start_crawl!
  build_job.save
end

#stop_crawl!Object



131
132
133
# File 'lib/lucid_works/datasource.rb', line 131

def stop_crawl!
  build_job.destroy
end