capitate 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ == 0.3.2 2008-04-03
2
+
3
+ * Adding hostname helper (utils.hostname)
4
+ * Adding sphinx_hostname var. Needed for delta conf.
5
+ * Updated example sphinx conf template
6
+
1
7
  == 0.3.1 2008-04-02
2
8
 
3
9
  * Fixing the init scripts to use killproc and have nice output (centos)
@@ -32,10 +32,12 @@ module Capitate::Plugins::Templates
32
32
  # Use first
33
33
  template_path = template_dirs_found.first + "/#{path}"
34
34
 
35
+ logger.info "reading #{template_path}"
35
36
  template_data = IO.read(template_path)
36
37
 
37
38
  if File.extname(template_path) == ".erb"
38
39
  template = ERB.new(template_data)
40
+ logger.info "evaluating #{template_path}"
39
41
  template_data = template.result(override_binding || binding)
40
42
  end
41
43
  template_data
@@ -110,6 +110,18 @@ module Capitate::Plugins::Utils
110
110
  found
111
111
  end
112
112
 
113
+ # Get the hostname of the remote server
114
+ #
115
+ # ==== Example
116
+ # utils.hostname => "localhost.localdomain"
117
+ #
118
+ def hostname
119
+ run "hostname" do |channel, stream, data|
120
+ return data.chomp
121
+ end
122
+ nil
123
+ end
124
+
113
125
  # Append data to a file.
114
126
  # Optionally check that it exists before adding.
115
127
  #
@@ -2,7 +2,7 @@ module Capitate #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -4,22 +4,24 @@ namespace :sphinx do
4
4
  desc <<-DESC
5
5
  Update sphinx for application.
6
6
 
7
- *sphinx_conf_template*: Path to sphinx.conf.erb. _Defaults to "config/templates/sphinx.conf.erb"_\n
8
- *sphinx_conf_path*: Path to sphinx.conf. _Defaults to "[shared_path]/config/sphinx.conf"_\n
9
- *sphinx_port*: Sphinx port. _Defaults to 3312_\n
10
- *sphinx_conf_root*: Directory for sphinx configuration, like stopwords.txt. _Defaults to [current_path]/config_\n
11
- *sphinx_index_root*: Directory for sphinx indexes. _Defaults to "[shared_path]/var/index"_\n
12
- *sphinx_log_root*: Directory for sphinx logs. _Defaults to "[shared_path]/log"_\n
13
- *sphinx_pid_root*: Directory for sphinx pids. _Defaults to "[shared_path]/pids"_\n
7
+ <dl>
8
+ <dt>sphinx_conf_template</dt><dd>Path to sphinx.conf.erb.</dd><dd>_Defaults to "config/templates/sphinx.conf.erb"_</dd>
9
+ <dt>sphinx_conf_path</dt><dd>Path to sphinx.conf.</dd><dd>_Defaults to "[shared_path]/config/sphinx.conf"_</dd>
10
+ <dt>sphinx_port</dt><dd>Sphinx port.</dd><dd>_Defaults to 3312_</dd>
11
+ <dt>sphinx_conf_root</dt><dd>Directory for sphinx configuration, like stopwords.txt.</dd><dd>_Defaults to [current_path]/config_</dd>
12
+ <dt>sphinx_index_root</dt><dd>Directory for sphinx indexes.</dd><dd>_Defaults to "[shared_path]/var/index"_</dd>
13
+ <dt>sphinx_log_root</dt><dd>Directory for sphinx logs.</dd><dd>_Defaults to "[shared_path]/log"_</dd>
14
+ <dt>sphinx_pid_root</dt><dd>Directory for sphinx pids.</dd><dd>_Defaults to "[shared_path]/pids"_</dd>
14
15
 
15
- *sphinx_db_user*: Sphinx DB user. _Defaults to db_user_\n
16
- *sphinx_db_pass*: Sphinx DB password. _Defaults to db_pass_\n
17
- *sphinx_db_name*: Sphinx DB name. _Defaults to db_name_\n
18
- *sphinx_db_port*: Sphinx DB port. _Defaults to db_port_\n
16
+ <dt>sphinx_db_user</dt><dd>Sphinx DB user.</dd><dd>_Defaults to db_user_</dd>
17
+ <dt>sphinx_db_pass</dt><dd>Sphinx DB password.</dd><dd>_Defaults to db_pass_</dd>
18
+ <dt>sphinx_db_name</dt><dd>Sphinx DB name.</dd><dd>_Defaults to db_name_</dd>
19
+ <dt>sphinx_db_port</dt><dd>Sphinx DB port.</dd><dd>_Defaults to db_port_</dd>
19
20
 
20
- *sphinx_db_host*: Sphinx DB host. _Defaults to db_host_\n
21
- *sphinx_conf_host*: Sphinx DB host to listen on. _Defaults to 127.0.0.1_\n
21
+ <dt>sphinx_db_host</dt><dd>Sphinx DB host.</dd><dd>_Defaults to db_host_</dd>
22
+ <dt>sphinx_conf_host</dt><dd>Sphinx DB host to listen on.</dd><dd>_Defaults to 127.0.0.1_</dd>
22
23
 
24
+ </dl>
23
25
  "Source":#{link_to_source(__FILE__)}
24
26
  DESC
25
27
  task :update_conf do
@@ -31,6 +33,7 @@ namespace :sphinx do
31
33
  fetch_or_default(:sphinx_index_root, "#{shared_path}/var/index")
32
34
  fetch_or_default(:sphinx_log_root, "#{shared_path}/log")
33
35
  fetch_or_default(:sphinx_pid_path, "#{shared_path}/pids/searchd.pid")
36
+ fetch_or_default(:sphinx_hostname, Proc.new { utils.hostname }) # Runs if needed
34
37
 
35
38
  fetch_or_set(:sphinx_db_user, :db_user)
36
39
  fetch_or_set(:sphinx_db_pass, :db_pass)
@@ -50,8 +53,8 @@ namespace :sphinx do
50
53
  desc <<-DESC
51
54
  Rotate sphinx index for application.
52
55
 
53
- *sphinx_prefix*: Location to sphinx install. _Defaults to nil_\n
54
- *sphinx_conf*: Location to sphinx conf. _Defaults to "[shared_path]/config/sphinx.conf"_\n
56
+ *sphinx_prefix*<dd>Location to sphinx install. _Defaults to nil_\n
57
+ *sphinx_conf*<dd>Location to sphinx conf. _Defaults to "[shared_path]/config/sphinx.conf"_\n
55
58
 
56
59
  "Source":#{link_to_source(__FILE__)}
57
60
  DESC
@@ -67,8 +70,8 @@ namespace :sphinx do
67
70
  desc <<-DESC
68
71
  Build sphinx indexes for application.
69
72
 
70
- *sphinx_prefix*: Location to sphinx install. _Defaults to nil_\n
71
- *sphinx_conf*: Location to sphinx conf. _Defaults to "[shared_path]/config/sphinx.conf"_\n
73
+ *sphinx_prefix*<dd>Location to sphinx install. _Defaults to nil_\n
74
+ *sphinx_conf*<dd>Location to sphinx conf. _Defaults to "[shared_path]/config/sphinx.conf"_\n
72
75
 
73
76
  "Source":#{link_to_source(__FILE__)}
74
77
  DESC
@@ -20,18 +20,41 @@ source pages
20
20
  sql_pass = <%= sphinx_db_pass %>
21
21
  sql_db = <%= sphinx_db_name %>
22
22
  sql_port = <%= sphinx_db_port %> # optional, default is 3306
23
- # sql_query_pre = SET CHARACTER_SET_RESULTS=cp1251
24
- sql_query_pre = SET NAMES UTF8
25
- # mandatory
26
- sql_query = QUERY
27
- sql_query_range = SELECT MIN(id),MAX(id) FROM TABLE_NAME
23
+
24
+ sql_query_pre = SET NAMES UTF8
25
+ sql_query_pre = SET SESSION query_cache_type=OFF
26
+ sql_query_pre = INSERT INTO indexer_status (id, started_at, status, index_name, hostname) VALUES (10, NOW(), 'indexing', 'pages', '<%= sphinx_hostname %>') \
27
+ ON DUPLICATE KEY UPDATE started_at = NOW(), status = 'indexing'
28
+
29
+ sql_query = SELECT id, user_id, language, UNIX_TIMESTAMP(created_at) AS created_at, UNIX_TIMESTAMP(updated_at) AS updated_at, body, title FROM pages WHERE id>=$start AND id<=$end
30
+ sql_query_range = SELECT MIN(id),MAX(id) FROM pages where type='Article'
28
31
  sql_range_step = 1000
29
- sql_group_column = user_id
30
- sql_group_column = language
31
- sql_date_column = published_date
32
- sql_date_column = last_modified
32
+
33
+ sql_query_post = UPDATE indexer_status SET updated_at = NOW(), status = 'updated' WHERE index_name = 'pages' and hostname = '<%= sphinx_hostname %>'
34
+
35
+ sql_attr_uint = user_id
36
+ sql_attr_timestamp = created_at
37
+ sql_attr_timestamp = updated_at
33
38
  }
34
39
 
40
+ source pages_delta : pages
41
+ {
42
+ # Clear and reset sql_query_pre
43
+ sql_query_pre =
44
+ sql_query_pre = SET NAMES UTF8
45
+ sql_query_pre = SET SESSION query_cache_type=OFF
46
+ sql_query_pre = INSERT INTO indexer_status (id, started_at, status, index_name, hostname) VALUES (11, NOW(), 'indexing', 'pages_delta', '<%= sphinx_hostname %>') \
47
+ ON DUPLICATE KEY UPDATE started_at = NOW(), status = 'indexing'
48
+
49
+ sql_query = SELECT id, user_id, language, UNIX_TIMESTAMP(created_at) AS created_at, UNIX_TIMESTAMP(updated_at) AS updated_at, body, title \
50
+ FROM pages \
51
+ WHERE updated_at >= (SELECT updated_at FROM indexer_status WHERE id = 11)
52
+
53
+ sql_query_post =
54
+ sql_query_post = UPDATE indexer_status SET updated_at = NOW(), status = 'updated' WHERE index_name = 'pages_delta' and hostname = '<%= sphinx_hostname %>'
55
+ sql_query_range =
56
+ sql_range_step =
57
+ }
35
58
 
36
59
  index pages
37
60
  {
@@ -46,6 +69,13 @@ index pages
46
69
  min_infix_len = 0
47
70
  }
48
71
 
72
+ index pages_delta : pages
73
+ {
74
+ source = pages_delta
75
+ path = <%= sphinx_index_root %>/pages_delta
76
+
77
+ }
78
+
49
79
  #############################################################################
50
80
  ## indexer settings
51
81
  #############################################################################
data/website/index.html CHANGED
@@ -35,7 +35,7 @@
35
35
 
36
36
  <div id="version" class="clickable box" onclick='document.location = "http://rubyforge.org/projects/capitate"; return false'>
37
37
  <p>Get Version</p>
38
- <a href="http://rubyforge.org/projects/capitate" class="numbers">0.3.1</a>
38
+ <a href="http://rubyforge.org/projects/capitate" class="numbers">0.3.2</a>
39
39
  </div>
40
40
 
41
41
  <div id="recipes">
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capitate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ""
6
6
  authors:
7
7
  - Gabriel Handford
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-04-02 00:00:00 -04:00
12
+ date: 2008-04-03 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency