directiverecord 0.1.2 → 0.1.3
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.
- checksums.yaml +8 -8
- data/CHANGELOG.rdoc +4 -0
- data/VERSION +1 -1
- data/lib/directive_record/gem_ext/active_record/base.rb +4 -0
- data/lib/directive_record/query/sql.rb +17 -0
- data/lib/directive_record/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjcwZWZhNjNhZThlMWQyOWU4NGIyNzE1YTRiNjQ5N2UzYWE2OGUzYQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjcxNWM5NTc2NzEzZTNiNTUwNjczMTA4MjAzMzUwMGViMTYzMjRlNA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NGFkZTNiN2EyN2NhZTc4YjE0ZjY2MjE0M2EwMGZiYjc2OGZjODk4OTE5MjZm
|
10
|
+
ZTIzZWQ3ZTRjODU3YWYxMDhmOTJiNTgwMWM1ODZmZWM3OTc1YzQ4YTczZjVi
|
11
|
+
Y2M3YWRiYjYxZTllNzIxMzU4MzFlMzQ3MDBiMTllNzMwYjdiNjY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDhmZWNlZDY2Njc1OWM4ZjM4NzkxMWI3ODhmMTJjZDU5NmM2MDU5M2YxNWJj
|
14
|
+
Y2Y5YWI4MGJhNTRmOTI1MWU5ZTc0M2Y3Y2VjMzUyNjBjOTk4Y2FjMjA2MTUz
|
15
|
+
OTU4NzE2M2E2YmM3YTA4OTZlOGIwMDBlYzdiMGM2MGYyMDk1MWQ=
|
data/CHANGELOG.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
@@ -9,6 +9,10 @@ module ActiveRecord
|
|
9
9
|
extract_connection(args).select_rows to_qry(*args)
|
10
10
|
end
|
11
11
|
|
12
|
+
def self.to_trend_qry(q1, q2, join_column_count, options)
|
13
|
+
DirectiveRecord::Query.new(self).to_trend_sql(q1, q2, join_column_count, options)
|
14
|
+
end
|
15
|
+
|
12
16
|
private
|
13
17
|
|
14
18
|
def self.extract_connection(args)
|
@@ -25,6 +25,23 @@ module DirectiveRecord
|
|
25
25
|
compose_sql options
|
26
26
|
end
|
27
27
|
|
28
|
+
def to_trend_sql(q1, q2, join_column_count, options)
|
29
|
+
i = join_column_count + 1
|
30
|
+
select = "q1.*, q2.c#{i}, (((q1.c#{i} - q2.c#{i}) / ABS(q2.c#{i})) * 100) AS trend"
|
31
|
+
on = (1..join_column_count).to_a.collect{|x| "q1.c#{x} = q2.c#{x}"}.join(" AND ")
|
32
|
+
order = "\nORDER BY #{options[:order]}" if options[:order]
|
33
|
+
limit = "\nLIMIT #{options[:limit]}" if options[:limit]
|
34
|
+
offset = "\nOFFSET #{options[:offset]}" if options[:offset]
|
35
|
+
<<-SQL
|
36
|
+
SELECT #{select}
|
37
|
+
FROM
|
38
|
+
(\n#{q1}\n) q1
|
39
|
+
INNER JOIN
|
40
|
+
(\n#{q2}\n) q2
|
41
|
+
ON #{on}#{order}#{limit}#{offset}
|
42
|
+
SQL
|
43
|
+
end
|
44
|
+
|
28
45
|
private
|
29
46
|
|
30
47
|
def path_delimiter; end
|