Commit a349834a0d3793128ade3df0dc6b5209355ebc52
1 parent
e493e3e1
Exists in
ratings_minor_fixes
and in
4 other branches
Remove obsolete sqlite extension
Showing
1 changed file
with
0 additions
and
28 deletions
Show diff stats
lib/sqlite_extension.rb
@@ -1,28 +0,0 @@ | @@ -1,28 +0,0 @@ | ||
1 | -if ApplicationRecord.connection.adapter_name.downcase == 'sqlite' | ||
2 | - | ||
3 | - database = ApplicationRecord.connection.raw_connection | ||
4 | - | ||
5 | - database.create_function('pow', 2, 1) do |func, base, exponent| | ||
6 | - func.set_result(base.to_f ** exponent.to_f) | ||
7 | - end | ||
8 | - | ||
9 | - database.create_function('sqrt', 1, 1) do |func, value| | ||
10 | - func.set_result(Math.sqrt(value)) | ||
11 | - end | ||
12 | - | ||
13 | - database.create_function('radians', 1, 1) do |func, value| | ||
14 | - func.set_result(value.to_f * Math::PI / 180.0) | ||
15 | - end | ||
16 | - | ||
17 | - database.create_function('spheric_distance', 5, 1) do |func, lat1, long1, lat2, long2, radius| | ||
18 | - func.set_result( | ||
19 | - radius.to_f * Math.acos( | ||
20 | - [1, | ||
21 | - Math.cos(lat1.to_f) * Math.cos(long1.to_f) * Math.cos(lat2.to_f) * Math.cos(long2.to_f) + | ||
22 | - Math.cos(lat1.to_f) * Math.sin(long1.to_f) * Math.cos(lat2.to_f) * Math.sin(long2.to_f) + | ||
23 | - Math.sin(lat1.to_f) * Math.sin(lat2.to_f) | ||
24 | - ].min | ||
25 | - ) | ||
26 | - ) | ||
27 | - end | ||
28 | -end |