diff options
-rw-r--r-- | app/controllers/request_controller.rb | 3 | ||||
-rw-r--r-- | app/models/incoming_message.rb | 1 | ||||
-rw-r--r-- | app/views/public_body/list.rhtml | 2 | ||||
-rw-r--r-- | app/views/request/list.rhtml | 2 | ||||
-rw-r--r-- | config/crontab.ugly | 2 | ||||
-rwxr-xr-x | script/update-xapian-index | 2 | ||||
-rw-r--r-- | spec/models/incoming_message_spec.rb | 7 | ||||
-rw-r--r-- | vendor/plugins/acts_as_xapian/lib/tasks/xapian.rake | 19 |
8 files changed, 28 insertions, 10 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index dad5e81cd..8672fdf75 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -35,9 +35,8 @@ class RequestController < ApplicationController # do nothing - as "authenticated?" has done the redirect to signin page for us return end - if !params[:query].nil? - query = params[:query] + '*' + query = params[:query] query = query.split(' ').join(' OR ') # XXX: HACK for OR instead of default AND! @xapian_requests = perform_search([PublicBody], query, 'relevant', nil, 5) end diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index a8498b6e8..20989d641 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -619,6 +619,7 @@ class IncomingMessage < ActiveRecord::Base end # Returns body text from main text part of email, converted to UTF-8 def get_main_body_text_internal + parse_raw_email! main_part = get_main_body_text_part return _convert_part_body_to_text(main_part) end diff --git a/app/views/public_body/list.rhtml b/app/views/public_body/list.rhtml index af91d8ed2..8cb207bd4 100644 --- a/app/views/public_body/list.rhtml +++ b/app/views/public_body/list.rhtml @@ -44,7 +44,7 @@ </div> <% end %> -<h2 class="publicbody_results"><%= _('Found {{count}} public bodies {{description}}', :count=>@public_bodies.size, :description=>@description) %></h2> +<h2 class="publicbody_results"><%= _('Found {{count}} public bodies {{description}}', :count=>@public_bodies.total_entries, :description=>@description) %></h2> <%= render :partial => 'body_listing', :locals => { :public_bodies => @public_bodies } %> <%= will_paginate(@public_bodies) %><br/> diff --git a/app/views/request/list.rhtml b/app/views/request/list.rhtml index 3890fa28b..63faf3643 100644 --- a/app/views/request/list.rhtml +++ b/app/views/request/list.rhtml @@ -18,7 +18,7 @@ <% if @list_results.empty? %> <p> <%= _('No requests of this sort yet.')%></p> <% else %> - <h2 class="foi_results"><%= _('{{count}} FOI requests found', :count => @list_results.size) %></h2> + <h2 class="foi_results"><%= _('{{count}} FOI requests found', :count => @matches_estimated) %></h2> <div class="results_block"> <% for result in @list_results%> <% if result.class.to_s == 'InfoRequestEvent' %> diff --git a/config/crontab.ugly b/config/crontab.ugly index 5f2fbdb3b..fdfd9f171 100644 --- a/config/crontab.ugly +++ b/config/crontab.ugly @@ -10,7 +10,7 @@ PATH=/usr/local/bin:/usr/bin:/bin MAILTO=cron-!!(*= $site *)!!@mysociety.org # Every 5 minutes -*/5 * * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/update-xapian-index.lock /data/vhost/!!(*= $vhost *)!!/!!(*= $vcspath *)!!/script/update-xapian-index || echo "stalled?" +*/5 * * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/update-xapian-index.lock /data/vhost/!!(*= $vhost *)!!/!!(*= $vcspath *)!!/script/update-xapian-index verbose=true >> /data/vhost/!!(*= $vhost *)!!/logs/update-xapian-index.log || echo "stalled?" # Every 10 minutes 5,15,25,35,45,55 * * * * !!(*= $user *)!! /etc/init.d/foi-alert-tracks check diff --git a/script/update-xapian-index b/script/update-xapian-index index 8d1fa7d0c..6ece02de0 100755 --- a/script/update-xapian-index +++ b/script/update-xapian-index @@ -1,5 +1,5 @@ #!/bin/bash cd `dirname $0` -rake --silent xapian:update_index +rake --silent xapian:update_index "$@" diff --git a/spec/models/incoming_message_spec.rb b/spec/models/incoming_message_spec.rb index 08d3d89f7..f514d6546 100644 --- a/spec/models/incoming_message_spec.rb +++ b/spec/models/incoming_message_spec.rb @@ -31,6 +31,13 @@ describe IncomingMessage, " when dealing with incoming mail" do end end + it "should ensure cached body text has been parsed correctly" do + ir = info_requests(:fancy_dog_request) + receive_incoming_mail('quoted-subject-iso8859-1.email', ir.incoming_email) + message = ir.incoming_messages[1] + message.get_main_body_text_unfolded.should_not include("Email has no body") + end + it "should correctly convert HTML even when there's a meta tag asserting that it is iso-8859-1 which would normally confuse elinks" do ir = info_requests(:fancy_dog_request) receive_incoming_mail('quoted-subject-iso8859-1.email', ir.incoming_email) diff --git a/vendor/plugins/acts_as_xapian/lib/tasks/xapian.rake b/vendor/plugins/acts_as_xapian/lib/tasks/xapian.rake index d18cd07d5..649d0c0d4 100644 --- a/vendor/plugins/acts_as_xapian/lib/tasks/xapian.rake +++ b/vendor/plugins/acts_as_xapian/lib/tasks/xapian.rake @@ -30,12 +30,23 @@ namespace :xapian do desc 'Completely rebuilds Xapian search index (must specify all models)' task :rebuild_index => :environment do + def coerce_arg(arg, default) + if arg == "false" + return false + elsif arg == "true" + return true + elsif arg.nil? + return default + else + return arg + end + end raise "specify ALL your models with models=\"ModelName1 ModelName2\" as parameter" if ENV['models'].nil? ActsAsXapian.rebuild_index(ENV['models'].split(" ").map{|m| m.constantize}, - ENV['verbose'] ? true : false, - ENV['terms'] == "false" ? false : ENV['terms'], - ENV['values'] == "false" ? false : ENV['values'], - ENV['texts'] == "false" ? false : true) + coerce_arg(ENV['verbose'], false), + coerce_arg(ENV['terms'], true), + coerce_arg(ENV['values'], true), + coerce_arg(ENV['textx'], true)) end # Parameters - are models, query, offset, limit, sort_by_prefix, |