lca 0.2.9 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +5 -5
- data/README.md +14 -1
- data/lib/generators/lca/templates/migration.rb.tt +0 -7
- data/lib/lca/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a856a2dadcc2f24d2668205c87824cf0efc26dc40b94011dbc37c644cc4e177
|
4
|
+
data.tar.gz: 4bd30ccb55f50fd474b84372e0e08bbd29efabf1ec393a489bd8ac97dfb7e8fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35136a03613252f3c9d3f6297f68993f5d834a62241397a6f358ed26af3fdf715c083b8daf9a7776451d93e948e2a91e91e5cebc338ad29069e55d8c3d047424
|
7
|
+
data.tar.gz: ede6826e7116952fc7d25f4b71b1f05a503c499e839e9f3e61f768a4e48103d6ff6924f6c01a516c3e30bfe2038e20359cc5913264b710df9e012351c627b007
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
lca (0.
|
5
|
-
active_tree (~> 0.
|
4
|
+
lca (0.3)
|
5
|
+
active_tree (~> 0.3)
|
6
6
|
activerecord (~> 6.0)
|
7
7
|
jwt (~> 2.2.3)
|
8
8
|
pg_ltree (~> 1.1.8)
|
@@ -10,7 +10,7 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
active_tree (0.
|
13
|
+
active_tree (0.3)
|
14
14
|
activerecord (~> 6.0)
|
15
15
|
jwt (~> 2.2.3)
|
16
16
|
pg_ltree (~> 1.1.8)
|
@@ -57,7 +57,7 @@ PLATFORMS
|
|
57
57
|
x86_64-linux
|
58
58
|
|
59
59
|
DEPENDENCIES
|
60
|
-
active_tree (~> 0.
|
60
|
+
active_tree (~> 0.3)
|
61
61
|
activerecord (~> 6.0)
|
62
62
|
jwt
|
63
63
|
lca!
|
@@ -66,4 +66,4 @@ DEPENDENCIES
|
|
66
66
|
rspec (~> 3.0)
|
67
67
|
|
68
68
|
BUNDLED WITH
|
69
|
-
2.2.
|
69
|
+
2.2.29
|
data/README.md
CHANGED
@@ -28,8 +28,17 @@ Upon installing the gem you must run the ActiveTree install process in your Rail
|
|
28
28
|
|
29
29
|
$ rails g active_tree:install
|
30
30
|
|
31
|
+
|
31
32
|
This will generate a `config/active_tree.yml` which you may customize to your needs, an initializer and a migration file which you can also customize to add any database columns your models will require.
|
32
33
|
|
34
|
+
You must also run the LCA gem install generator:
|
35
|
+
|
36
|
+
$ rails g lca:install
|
37
|
+
|
38
|
+
|
39
|
+
This will create a migration file which you can edit to add your models' specific attributes.
|
40
|
+
|
41
|
+
|
33
42
|
## Usage
|
34
43
|
|
35
44
|
Include the ActiveTree concern into one of your models which will own lifecycle trees (owner model):
|
@@ -46,7 +55,7 @@ This will extend your model and enable the following functionality:
|
|
46
55
|
```ruby
|
47
56
|
# query with ActiveRecord syntax
|
48
57
|
User.last.active_trees
|
49
|
-
User.find_by(name: "Acme").
|
58
|
+
User.find_by(name: "Acme").active_trees.impacts.select("impact_unit, sum(impact_amount) as total_impact").group(:impact_unit)
|
50
59
|
User.last.active_trees.where(...)
|
51
60
|
User.last.active_trees.where(...).group(...)
|
52
61
|
User.last.active_trees.where(...).limit(...).offset(...)
|
@@ -87,6 +96,10 @@ To see what syntax to use for path traversal please check out the following reso
|
|
87
96
|
* pg_ltree gem https://github.com/sjke/pg_ltree
|
88
97
|
* Postgres ltree extension documentation https://www.postgresql.org/docs/9.1/ltree.html
|
89
98
|
|
99
|
+
## Scalability
|
100
|
+
|
101
|
+
All LCA data can be stored into separate partitions using the ActiveTree partitioning feature. See `config/active_tree.yml` for table and partitioning naming and options.
|
102
|
+
|
90
103
|
## Caveats
|
91
104
|
|
92
105
|
`pg_ltree` .child / .parent queries do not work across different models due to an ActiveRecord limitation that requires results to be related via inheritance.
|
@@ -1,13 +1,6 @@
|
|
1
1
|
class <%= migration_class_name %> < ActiveRecord::Migration<%= migration_version %>
|
2
2
|
def change
|
3
3
|
|
4
|
-
# enable ltree extension
|
5
|
-
begin
|
6
|
-
execute "create extension ltree"
|
7
|
-
rescue
|
8
|
-
p "LTREE was already enabled"
|
9
|
-
end
|
10
|
-
|
11
4
|
# add any columns required by your business model
|
12
5
|
add_column ACTIVE_TREE_OPTIONS[:table_name], :impact_amount, :decimal
|
13
6
|
add_column ACTIVE_TREE_OPTIONS[:table_name], :impact_amount_previous, :decimal
|
data/lib/lca/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lca
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick @ Earthster
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: '0.3'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: '0.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: pg_ltree
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|