Skip to content

Commit

Permalink
Merge branch 'release/v4.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
pat committed Aug 21, 2019
2 parents 2083f03 + 9768200 commit 3918100
Show file tree
Hide file tree
Showing 14 changed files with 118 additions and 24 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
language: ruby
dist: xenial
rvm:
- 2.3.8
- 2.4.6
- 2.5.5
- 2.6.2
- 2.6.3
before_install:
- pip install --upgrade --user awscli
- gem update --system
Expand Down Expand Up @@ -36,6 +37,9 @@ env:
sudo: false
addons:
postgresql: '9.4'
apt:
packages:
- libodbc1
services:
- mysql
- postgresql
2 changes: 1 addition & 1 deletion Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ appraise 'rails_5_2' do
end if RUBY_PLATFORM != 'java'

appraise 'rails_6_0' do
gem 'rails', '~> 6.0.0.beta1'
gem 'rails', '~> 6.0.0'
gem 'mysql2', '~> 0.5.0', :platform => :ruby
gem 'pg', '~> 1.0', :platform => :ruby
end if RUBY_PLATFORM != 'java' && RUBY_VERSION.to_f >= 2.5
17 changes: 17 additions & 0 deletions CHANGELOG.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@

All notable changes to this project (at least, from v3.0.0 onwards) are documented in this file.

## 4.4.0 - 2019-08-21

[Release Notes](https://github.com/pat/thinking-sphinx/releases/tag/v4.4.0)

### Added

* Confirmed Rails 6.0 support.
* Added ability to have custom real-time index processors (which handles all indices) and populators (which handles a particular index). These are available to get/set via `ThinkingSphinx::RealTime.processor` and `ThinkingSphinx::RealTime.populator` (and discussed in more detail in the [release notes](https://github.com/pat/thinking-sphinx/releases/tag/v4.4.0)).

### Changed

* Improve failure message when tables don't exist for models associated with Sphinx indices ([Kiril Mitov](https://github.com/thebravoman) in [#1139](https://github.com/pat/thinking-sphinx/pull/1139)).

### Fixed

* Injected has-many/habtm collection search calls as default extensions to associations in Rails 5+, as it's a more reliable approach in Rails 6.0.0.

## 4.3.2 - 2019-07-10

[Release Notes](https://github.com/pat/thinking-sphinx/releases/tag/v4.3.2)
Expand Down
2 changes: 1 addition & 1 deletion README.textile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
h1. Thinking Sphinx

Thinking Sphinx is a library for connecting ActiveRecord to the Sphinx full-text search tool, and integrates closely with Rails (but also works with other Ruby web frameworks). The current release is v4.3.2.
Thinking Sphinx is a library for connecting ActiveRecord to the Sphinx full-text search tool, and integrates closely with Rails (but also works with other Ruby web frameworks). The current release is v4.4.0.

h2. Upgrading

Expand Down
20 changes: 15 additions & 5 deletions bin/loadsphinx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
version=$1
engine=$2

set -e

load_sphinx () {
distro="xenial"

case $version in
2.1.9)
url="http://sphinxsearch.com/files/sphinxsearch_2.1.9-release-0ubuntu11~trusty_amd64.deb"
format="deb";;
format="deb"
distro="trusty";;
2.2.11)
url="http://sphinxsearch.com/files/sphinxsearch_2.2.11-release-1~trusty_amd64.deb"
url="http://sphinxsearch.com/files/sphinxsearch_2.2.11-release-1~xenial_amd64.deb"
format="deb";;
3.0.3)
url="http://sphinxsearch.com/files/sphinx-3.0.3-facc3fb-linux-amd64.tar.gz"
Expand All @@ -22,6 +27,11 @@ load_sphinx () {
exit 1;;
esac

if [ "$distro" == "trusty" ]; then
curl --location http://launchpadlibrarian.net/247512886/libmysqlclient18_5.6.28-1ubuntu3_amd64.deb -o libmysql.deb
sudo apt-get install ./libmysql.deb
fi

if [ "$format" == "deb" ]; then
curl --location $url -o sphinx.deb
sudo apt-get install ./sphinx.deb
Expand All @@ -37,11 +47,11 @@ load_manticore () {

case $version in
2.6.4)
url="https://github.com/manticoresoftware/manticoresearch/releases/download/2.6.4/manticore_2.6.4-180503-37308c3-release-stemmer.trusty_amd64-bin.deb";;
url="https://github.com/manticoresoftware/manticoresearch/releases/download/2.6.4/manticore_2.6.4-180503-37308c3-release-stemmer.xenial_amd64-bin.deb";;
2.7.5)
url="https://github.com/manticoresoftware/manticoresearch/releases/download/2.7.5/manticore_2.7.5-181204-0f016406-release-stemmer.trusty_amd64-bin.deb";;
url="https://github.com/manticoresoftware/manticoresearch/releases/download/2.7.5/manticore_2.7.5-181204-4a31c54-release-stemmer.xenial_amd64-bin.deb";;
2.8.2)
url="https://github.com/manticoresoftware/manticoresearch/releases/download/2.8.2/manticore_2.8.2-190402-4e81114-release-stemmer.trusty_amd64-bin.deb";;
url="https://github.com/manticoresoftware/manticoresearch/releases/download/2.8.2/manticore_2.8.2-190402-4e81114-release-stemmer.xenial_amd64-bin.deb";;
*)
echo "No Manticore version $version available"
exit 1;;
Expand Down
3 changes: 1 addition & 2 deletions lib/thinking_sphinx/active_record/association_proxy.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

module ThinkingSphinx::ActiveRecord::AssociationProxy
extend ActiveSupport::Concern

def search(query = nil, options = {})
perform_search super(*normalise_search_arguments(query, options))
end
Expand All @@ -12,6 +10,7 @@ def search_for_ids(query = nil, options = {})
end

private

def normalise_search_arguments(query, options)
query, options = nil, query if query.is_a?(Hash)
options[:ignore_scopes] = true
Expand Down
19 changes: 17 additions & 2 deletions lib/thinking_sphinx/active_record/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,23 @@ module ThinkingSphinx::ActiveRecord::Base
after_update ThinkingSphinx::ActiveRecord::Callbacks::UpdateCallbacks
after_commit ThinkingSphinx::ActiveRecord::Callbacks::DeltaCallbacks

::ActiveRecord::Associations::CollectionProxy.send :include,
ThinkingSphinx::ActiveRecord::AssociationProxy
if ActiveRecord::VERSION::STRING.to_i >= 5
[
::ActiveRecord::Reflection::HasManyReflection,
::ActiveRecord::Reflection::HasAndBelongsToManyReflection
].each do |reflection_class|
reflection_class.include DefaultReflectionAssociations
end
else
::ActiveRecord::Associations::CollectionProxy.send :include,
ThinkingSphinx::ActiveRecord::AssociationProxy
end
end

module DefaultReflectionAssociations
def extensions
super + [ThinkingSphinx::ActiveRecord::AssociationProxy]
end
end

module ClassMethods
Expand Down
4 changes: 1 addition & 3 deletions lib/thinking_sphinx/commands/index_real_time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

class ThinkingSphinx::Commands::IndexRealTime < ThinkingSphinx::Commands::Base
def call
options[:indices].each do |index|
ThinkingSphinx::RealTime::Populator.populate index

ThinkingSphinx::RealTime.processor.call options[:indices] do
command :rotate
end
end
Expand Down
6 changes: 5 additions & 1 deletion lib/thinking_sphinx/core/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ def document_id_for_key(key)
end

def interpret_definition!
return unless model.table_exists?
table_exists = model.table_exists?
unless table_exists
Rails.logger.info "No table exists for #{model}. Index can not be created"
return
end
return if @interpreted_definition

apply_defaults!
Expand Down
17 changes: 17 additions & 0 deletions lib/thinking_sphinx/real_time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@ module Callbacks
def self.callback_for(reference, path = [], &block)
Callbacks::RealTimeCallbacks.new reference.to_sym, path, &block
end

def self.populator
@populator ||= ThinkingSphinx::RealTime::Populator
end

def self.populator=(value)
@populator = value
end

def self.processor
@processor ||= ThinkingSphinx::RealTime::Processor
end

def self.processor=(value)
@processor = value
end
end

require 'thinking_sphinx/real_time/property'
Expand All @@ -16,6 +32,7 @@ def self.callback_for(reference, path = [], &block)
require 'thinking_sphinx/real_time/index'
require 'thinking_sphinx/real_time/interpreter'
require 'thinking_sphinx/real_time/populator'
require 'thinking_sphinx/real_time/processor'
require 'thinking_sphinx/real_time/transcribe_instance'
require 'thinking_sphinx/real_time/transcriber'
require 'thinking_sphinx/real_time/translator'
Expand Down
2 changes: 1 addition & 1 deletion lib/thinking_sphinx/real_time/populator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def initialize(index)
@index = index
end

def populate(&block)
def populate
instrument 'start_populating'

scope.find_in_batches(:batch_size => batch_size) do |instances|
Expand Down
36 changes: 36 additions & 0 deletions lib/thinking_sphinx/real_time/processor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# frozen_string_literal: true

class ThinkingSphinx::RealTime::Processor
def self.call(indices, &block)
new(indices).call(&block)
end

def initialize(indices)
@indices = indices
end

def call(&block)
subscribe_to_progress

indices.each do |index|
ThinkingSphinx::RealTime.populator.populate index

block.call
end
end

private

attr_reader :indices

def command
ThinkingSphinx::Commander.call(
command, configuration, options, stream
)
end

def subscribe_to_progress
ThinkingSphinx::Subscribers::PopulatorSubscriber.
attach_to 'thinking_sphinx.real_time'
end
end
4 changes: 0 additions & 4 deletions lib/thinking_sphinx/subscribers/populator_subscriber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,3 @@ def finish_populating(event)
delegate :output, :to => ThinkingSphinx
delegate :puts, :print, :to => :output
end

ThinkingSphinx::Subscribers::PopulatorSubscriber.attach_to(
'thinking_sphinx.real_time'
)
4 changes: 1 addition & 3 deletions thinking-sphinx.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $:.push File.expand_path('../lib', __FILE__)

Gem::Specification.new do |s|
s.name = 'thinking-sphinx'
s.version = '4.3.2'
s.version = '4.4.0'
s.platform = Gem::Platform::RUBY
s.authors = ["Pat Allan"]
s.email = ["[email protected]"]
Expand All @@ -14,8 +14,6 @@ Gem::Specification.new do |s|
s.description = %Q{An intelligent layer for ActiveRecord (via Rails and Sinatra) for the Sphinx full-text search tool.}
s.license = 'MIT'

s.rubyforge_project = 'thinking-sphinx'

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f|
Expand Down

0 comments on commit 3918100

Please sign in to comment.