Support of HAVING for Sphinx running in Heroku - heroku

I have the following query:
search(params[:query],
with: { tag_id: params[:filter].values.flatten },
group_by: :technology_id,
having: "COUNT(*)=#{params[:filter].size}"
)
This is working locally, but when I deploy to heroku it throws:
ActionView::Template::Error (sphinxql: syntax error, unexpected IDENT, expecting $end
near 'HAVING COUNT(*)=1 LIMIT 0, 20; SHOW META' - SELECT *, groupby() AS
sphinx_internal_group, id AS sphinx_document_id, count(DISTINCT sphinx_document_id) AS
sphinx_internal_count FROM `technology_core` WHERE MATCH('cancer') AND `tag_id` IN (1) AND
`sphinx_deleted` = 0 GROUP BY `technology_id` HAVING COUNT(*)=1 LIMIT 0, 20; SHOW META):
The sphinx version is specified as follows:
# config/thinking_sphinx.yml
test:
mysql41: 9307
production:
version: '2.2.6'
Anyone knows what else could be?

At this point in time, the latest Sphinx version available on Flying Sphinx servers is 2.2.3 - can you change the version in your thinking_sphinx.yml, deploy and run rebuild/regenerate, and see if HAVING works?

Related

changing CRS in GeoPandas

I'm trying to change the CRS of a geopandas dataframe. The current CRS is:
Name: unknown
Axis Info [ellipsoidal]:
- lon[east]: Longitude (degree)
- lat[north]: Latitude (degree)
Area of Use:
- undefined
Datum: World Geodetic System 1984
- Ellipsoid: WGS 84
- Prime Meridian: Greenwich
When I try dfTrans.to_crs('epsg:4326') I get the following error:
pyproj.exceptions.CRSError: Invalid projection: epsg:4326: (Internal Proj Error: proj_create: cannot build geodeticCRS 4326: SQLite error on SELECT name, ellipsoid_auth_name, ellipsoid_code, prime_meridian_auth_name, prime_meridian_code, area_of_use_auth_name, area_of_use_code, publication_date, deprecated FROM geodetic_datum WHERE auth_name = ? AND code = ?: no such column: publication_date)
For a simple command in pyproj, pyproj.CRS.from_epsg(4326), I get the same error:
File "pyproj/_crs.pyx", line 1738, in pyproj._crs._CRS.__init__
pyproj.exceptions.CRSError: Invalid projection: epsg:4326: (Internal Proj Error: proj_create: cannot build geodeticCRS 4326: SQLite error on SELECT name, ellipsoid_auth_name, ellipsoid_code, prime_meridian_auth_name, prime_meridian_code, area_of_use_auth_name, area_of_use_code, publication_date, deprecated FROM geodetic_datum WHERE auth_name = ? AND code = ?: no such column: publication_date)
I don't know enough to know what's going on, but it seems like there's an underlying function that calls a column that doesn't exist. Any ideas how to fix this or work around it?
I got that same error when using Proj-5.x. It seems that the 'publication_date' column is a Proj-6 or Proj-7 item (which both require SQLite.)

nativescript paytm plugin giving 404 Not Found Error nginx/1.6.2

I'm trying to integrate #nstudio/nativescript-paytm plugin into my app.
as a part the first step i have written code to generate checksum. now i'm getting checksum. if i passed this to further steps as I'm getting below error.
Error in console
chromium: [INFO:library_loader_hooks.cc(50)] Chromium logging enabled: level = 0, default verbosity = 0
06-22 07:31:56.479 2762 2762 I cr_BrowserStartup: Initializing chromium process, singleProcess=true
chromium: [ERROR:filesystem_posix.cc(89)] stat /data/user/0/org.nativescript.demo/cache/WebView/Crashpad: No such file or directory (2)
chromium: [ERROR:filesystem_posix.cc(62)] mkdir /data/user/0/org.nativescript.demo/cache/WebView/Crashpad: No such file or directory (2)
My order param is
var order = {
MID: "V************3",
ORDER_ID: "order1",
CUST_ID: "cust123",
INDUSTRY_TYPE_ID: "Retail",
CHANNEL_ID: "WEB",
TXN_AMOUNT: "100.12",
WEBSITE: "WEBSTAGING",
CALLBACK_URL: "https://pguat.paytm.com/paytmchecksum/paytmCallback.jsp",
CHECKSUMHASH: "NDspZhvSHbq44K3A9Y4daf9En3l2Ndu9fmOdLG+bIwugQ6682Q3JiNprqmhiWAgGUnNcxta3LT2Vtk3EPwDww8o87A8tyn7/jAS2UAS9m+c="
};
I'm using github sample of that plugin(javascript version i.e demo) i haven't modified the code.

cucumber ActiveRecord::ConnectionNotEstablished

The exception I am getting is "ActiveRecord::ConnectionNotEstablished: No connection pool for ActiveRecord::Base". I am really on the deep end of the pool (no pun intended) with this one. I really don't understand the connection and connection pool handling, even as much as I have studied this problem. I'm assuming this might be scope related inside of Cucumber, but I do not know. Any and all assistance is appreciated.
Here are the details:
The exception occurs when I perform a count from a Then clause:
WorkTable.where('? is not null',col['COLUMN_NAME']).count
It does not occur if I send the sql directly through the connection:
WorkTable.connection.select_all(st.encode('utf-8')).first['nulls']
My scenario reads as follows:
Scenario: CompanyMaster test for null value
Given table dbo.base_table in stage
Then these columns are expected to be not null
| COLUMN_NAME | nulls |
| id | 0 |
| company_name | 0 |
I establish my class in my env.rb:
class WorkTable < ActiveRecord::Base
end
ActiveRecord::Base.configurations = YAML.load_file(yaml) # yaml is database.yml file name
I establish my connection in a Given clause:
Given(/^table (\w+)\.?([\w_]+) in (\w+)(?: as (\w+))?$/) do |schema,name,env,id|
#sc_name = schema_file_name(schema,name)
WorkTable.logger.info title_line("* Active table(#{#sc_name}) *")
case id
# ActiveRecord::Base.configurations[env]
...
else
WorkTable.table_name = #sc_name
WorkTable.establish_connection(env.to_sym)
# ary = get_tables(WorkTable,schema:schema)
# expect( ary.any?{|s| s.casecmp(name)==0 } ).to eq(true)
end
end
I execute my test in a Then clause:
Then(/^these columns are expected to be not null$/) do |columns|
# expected is an instance of Cucumber::Ast::Table
WorkTable.logger.info title_line('Columns cannot be null')
results = []
columns.hashes.each {|col|
results << {
'COLUMN_NAME' => col['COLUMN_NAME'],
'nulls' => WorkTable.where('? is not null',col['COLUMN_NAME']).count.to_s
}
}
columns.diff!(results,surplus_row: false)
end
It is the WorkTable.where that throws the "ActiveRecord::ConnectionNotEstablished: No connection pool for ActiveRecord::Base". Again, if I use the WorkTable.connection method, I do not get it. Also, it executes fine if I copy all the function code to single ruby script.
I see the following when I "pp WorkTable.connection":
#<ActiveRecord::ConnectionAdapters::SQLServerAdapter version: 4.2.2, mode: dblib, azure: false>
And I see the following when I "pp WorkTable.connection_pool":
#<ActiveRecord::ConnectionAdapters::ConnectionPool:0x42f5238
#automatic_reconnect=true,
#available=
#<ActiveRecord::ConnectionAdapters::ConnectionPool::Queue:0x42f4f20
#cond=
#<MonitorMixin::ConditionVariable:0x42f4ed8
#cond=
#<ConditionVariable:0x42f4de8
#waiters=[],
#waiters_mutex=#<Mutex:0x42f4d58>>,
#monitor=
#<ActiveRecord::ConnectionAdapters::ConnectionPool:0x42f5238 ...>>,
#lock=#<ActiveRecord::ConnectionAdapters::ConnectionPool:0x42f5238 ...>,
#num_waiting=0,
#queue=[]>,
#checkout_timeout=5,
#connections=
[#<ActiveRecord::ConnectionAdapters::SQLServerAdapter version: 4.2.2, mode: dblib, azure: false>],
#mon_count=0,
#mon_mutex=#<Mutex:0x42f51c0>,
#mon_owner=nil,
#reaper=
#<ActiveRecord::ConnectionAdapters::ConnectionPool::Reaper:0x42f51a8
#frequency=nil,
#pool=#<ActiveRecord::ConnectionAdapters::ConnectionPool:0x42f5238 ...>>,
#reserved_connections=
#<ThreadSafe::Cache:0x42f4fc8
#backend=
{16931712=>
#<ActiveRecord::ConnectionAdapters::SQLServerAdapter version: 4.2.2, mode: dblib, azure: false>},
#default_proc=nil>,
#size=5,
#spec=
#<ActiveRecord::ConnectionAdapters::ConnectionSpecification:0x42f55c8
#adapter_method="sqlserver_connection",
#config=
{:host=>"server_name",
:database=>"mssb_stg",
:encoding=>"utf-8",
:adapter=>"sqlserver",
:timeout=>5000}>>
Ruby 1.9.3, activerecord (4.2.0), activerecord-sqlserver-adapter (4.2.2), and cucumber (1.3.18). And sql server 2014 [this has been a bugger for me].
Thank you for you time and consideration.
dvn
== Additional detail ==
Ignore the sql-server reference. I get the same exception when I reconfigure to work with SqLite. So it is not related to db platform.
Check your env.rb, conf in supports, it seems you are making connections in steps, ideally you should do it in before_scenario or before feature file rather than per steps.
It could be possible after steps your connection is not working properly.

Can't upload images to Redmine anymore

For some strange reason I can't upload images to tickets in Redmine anymore. I can upload a txt file or zip files. When I upload an image in the ticket it either says "Service Unavailable" or "Unprocessable". Weird thing is that it used to work. We updated to the latest Redmine (2.6.0.stable)
I looked at the production.log and this is the error (Can't verify CSRF token authenticity):
Started POST "/uploads.js?attachment_id=1&filename=test.png" for xx.xx.xxx.xxx at 2014-12-03 12:58:49 -0500
Processing by AttachmentsController#upload as JS
Parameters: {"attachment_id"=>"1", "filename"=>"test.png"}
WARNING: Can't verify CSRF token authenticity
Filter chain halted as :verify_authenticity_token rendered or redirected
Completed 422 Unprocessable Entity in 2.6ms (ActiveRecord: 0.3ms)
Here is my Redmine Information:
Default administrator account changed True
Attachments directory writable True
Plugin assets directory writable True
RMagick available (optional) Exclamation
ImageMagick convert available (optional) True
Environment:
Redmine version 2.6.0.stable
Ruby version 1.9.3-p547 (2014-05-14) [x86_64-linux]
Rails version 3.2.19
Environment production
Database adapter Mysql2
SCM:
Git 1.8.2.1
Filesystem
Redmine plugins:
redmine_agile 1.3.2
redmine_ckeditor 1.0.16
redmine_github_hook 2.1.0
redmine_my_page_queries 2.1.6
redmine_theme_changer 0.1.0
It turns out that this was a Varnish Issue. We got around this problem by adding this Varnish rule:
if (req.http.host ~ "my\.domain\.com$") {
return (pipe);
}
Here are some debugging things we did to try to figure out the problem.
Temporarily added config.action_controller.allow_forgery_protection = false to application.rb. When we tried to upload an image it I get a Popup: login required for Server on Redmine API. This gave me a clue that it must have been some kind of server issue.
Created additional_environment.rb and enabled config.log_level = :debug. This added more debug info to the log file.
Started POST "/uploads.js?attachment_id=1&filename=Screen%20Shot%202014-12-11%20at%2010.01.49%20AM.png" for xx.xx.xxx.xxx at 2014-12-11 11:07:41 -0500
Processing by AttachmentsController#upload as JS
Parameters: {"attachment_id"=>"1", "filename"=>"Screen Shot 2014-12-11 at 10.01.49 AM.png"}
^[[1m^[[35m (0.3ms)^[[0m SELECT MAX(`settings`.`updated_on`) AS max_id FROM `settings`
^[[1m^[[36mSetting Load (0.3ms)^[[0m ^[[1mSELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'rest_api_enabled' LIMIT 1^[[0m
^[[1m^[[35mAnonymousUser Load (0.3ms)^[[0m SELECT `users`.* FROM `users` WHERE `users`.`type` IN ('AnonymousUser') LIMIT 1
Current user: anonymous
^[[1m^[[36mSetting Load (0.3ms)^[[0m ^[[1mSELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'login_required' LIMIT 1^[[0m
^[[1m^[[35mSetting Load (0.2ms)^[[0m SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'force_default_language_for_anonymous' LIMIT 1
^[[1m^[[36mSQL (1.2ms)^[[0m ^[[1mSELECT `members`.`id` AS t0_r0, `members`.`user_id` AS t0_r1, `members`.`project_id` AS t0_r2, `members`.`created_on` AS t0_r3, `members`.`mail_notification` AS t0_r4, `projects`.`id` AS t1_r0, `projects`.`name` AS t1_r1, `projects`.`description` AS t1_r2, `projects`.`homepage` AS t1_r3, `projects`.`is_public` AS t1_r4, `projects`.`parent_id` AS t1_r5, `projects`.`created_on` AS t1_r6, `projects`.`updated_on` AS t1_r7, `projects`.`identifier` AS t1_r8, `projects`.`status` AS t1_r9, `projects`.`lft` AS t1_r10, `projects`.`rgt` AS t1_r11, `projects`.`inherit_members` AS t1_r12, `roles`.`id` AS t2_r0, `roles`.`name` AS t2_r1, `roles`.`position` AS t2_r2, `roles`.`assignable` AS t2_r3, `roles`.`builtin` AS t2_r4, `roles`.`permissions` AS t2_r5, `roles`.`issues_visibility` AS t2_r6 FROM `members` LEFT OUTER JOIN `projects` ON `projects`.`id` = `members`.`project_id` LEFT OUTER JOIN `member_roles` ON `member_roles`.`member_id` = `members`.`id` LEFT OUTER JOIN `roles` ON `roles`.`id` = `member_roles`.`role_id` WHERE `members`.`user_id` = 2 AND (projects.status<>9) ORDER BY projects.name^[[0m
^[[1m^[[35mRole Load (0.2ms)^[[0m SELECT `roles`.* FROM `roles` WHERE `roles`.`builtin` = 2 LIMIT 1
Filter chain halted as :authorize_global rendered or redirected
Completed 401 Unauthorized in 54.3ms (ActiveRecord: 2.7ms)
Current user: anonymous in the log kind of helped lead to the fix.

thinking sphinx unknown type 'mysql'; skipping

I'm using ts version 2.0.5, rails 3.0.9 and mysql2 0.2.11
When trying to create my indexes, using rake ts:index, I get the following error:
ERROR: source 'technical_core_0': unknown type 'mysql'; skipping.
My development.sphinx.conf contains:
source technical_core_0
{
type = mysql
sql_host = localhost
sql_user = root
sql_pass =
sql_db = ps_development
sql_sock = /tmp/mysql.sock
sql_query_pre = SET NAMES utf8
sql_query_pre = SET TIME_ZONE = '+0:00'
sql_query = SELECT SQL_NO_CACHE `technicals`.`id` * CAST(1 AS SIGNED) + 0 AS `id` , `orders`.`name` AS `author`, `technicals`.`id` AS `sphinx_internal_id`, 0 AS `sphinx_deleted`, 488243725 AS `class_crc`, IFNULL(`orders`.`name`, '') AS `author_sort`, `technicals`.`order_id` AS `order_id`, UNIX_TIMESTAMP(`technicals`.`created_at`) AS `created_at`, UNIX_TIMESTAMP(`technicals`.`updated_at`) AS `updated_at` FROM `technicals` LEFT OUTER JOIN `orders` ON `orders`.`id` = `technicals`.`order_id` WHERE (`technicals`.`id` >= $start AND `technicals`.`id` <= $end) GROUP BY `technicals`.`id`, , `orders`.`name`, `technicals`.`id`, `orders`.`name`, `technicals`.`order_id`, `technicals`.`created_at`, `technicals`.`updated_at` ORDER BY NULL
sql_query_range = SELECT IFNULL(MIN(`id`), 1), IFNULL(MAX(`id`), 1) FROM `technicals`
sql_attr_uint = sphinx_internal_id
sql_attr_uint = sphinx_deleted
sql_attr_uint = class_crc
sql_attr_uint = order_id
sql_attr_timestamp = created_at
sql_attr_timestamp = updated_at
sql_attr_str2ordinal = author_sort
sql_query_info = SELECT * FROM `technicals` WHERE `id` = (($id - 0) / 1)
}
Which is a bit odd as my database.yml file contains mysql2 and a root password.
Can you help me get past this stage? I tried also creating a sphinx.yml file with:
development:
adapter: mysql2
But this also fails.
-- UPDATE --
I added this into the development initialisers file:
ThinkingSphinx.database_adapter = :mysql2
Which gives error about only MySQL being supported.
As per the link here, you could simply do the following on homebrew (mac):
brew install sphinx --with-mysql
That worked for me :)
When you are compiling Sphinx you should specify the --with-mysql flag.
$ ./configure --with-mysql
$ make
$ sudo make install
You might need to specify the location of your MySQL library's include files. For example on a fresh installation of OS X:
$ ./configure --with-mysql=/opt/local/include/mysql5
Also when installing on OSX via homebrew try this:
sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql
brew install --interactive sphinx
./configure
make
make install
exit
The generated source looks correct - is it possible your version of Sphinx was compiled without MySQL support?

Resources