Commit Graph

525 Commits

Author SHA1 Message Date
Keenan Brock 98c47da4be
Merge pull request #476 from mmoll/travis_pg
Fix DB detection for Travis build
2020-04-30 13:12:43 -04:00
Michael Moll 059023dc10 Fix DB detection for Travis build 2020-04-23 21:01:23 +02:00
Keenan Brock 741042f40b
Merge pull request #475 from yagudaev/patch-1
Update readme instructions for migration
2020-02-28 20:22:44 -05:00
Michael Yagudaev ea69cca6b0
Update outdated rails console insturction
Update the outdated `./script` directory which is no longer part of rails, to simply run rails console.
2020-02-24 14:49:29 -08:00
Keenan Brock 5f11226424
Merge pull request #472 from kbrock/setter_tests
test setting parent and parent_id set the other
2019-12-26 18:32:17 -05:00
Keenan Brock a4fec48635 test setting parent and parent_id set the other 2019-12-12 15:44:02 -05:00
Minh Nguyen-Hue 4462c6b795 Address code review 2019-10-17 12:20:06 +07:00
Minh Nguyen-Hue ebd025b23a Update README for optimization 2019-10-16 12:32:02 +07:00
Minh Nguyen-Hue 356cc0e6dc Add optimizer for postgres
# Summary

Currently, there is no way to make optimization for a specific
database.
This commit is to give an approach to help developer use specific
database technique to do optimization.
For examples, the origin `update_descendants_with_new_ancestry` has a
lot of N+1 queries to update all descendants. By using
`regexp_replace` on Postgres, we can use one query to remove N+1.
2019-10-16 12:24:17 +07:00
Keenan Brock 07340aeb1b
Merge pull request #462 from dtamai/visual-doc
Add graph examples in documentation
2019-10-02 19:46:57 -04:00
Keenan Brock 02720f46bc
Merge pull request #463 from dtamai/add-indirects-navigation-tests
Add tests for indirects in TreeNavigationTest
2019-10-02 19:12:49 -04:00
Daniel Tamai c4aea62750 Add tests for indirects in TreeNavigationTest 2019-10-01 22:14:07 -03:00
Daniel Tamai 27c0d12adb Add graph examples in documentation 2019-10-01 20:17:21 -03:00
Keenan Brock cebffcaec1
Merge pull request #460 from kbrock/update-update_attribute
test fixes
2019-09-11 11:13:37 -04:00
Keenan Brock 661881a5f1 test around cache counter
I was going to change the way changed used the column name
in the update_cache_counter code. (the purpose of this branch)

Decided to roll that change back, but this test still looks good
2019-09-11 11:08:14 -04:00
Keenan Brock b810976185 use ancestor_ids in test
going towards using ancestor_ids and getting away from using
ancestry_column.
2019-09-11 10:11:47 -04:00
Keenan Brock 188f7bda18
Merge pull request #459 from kbrock/delimiter_definition
Delimiter definition
2019-09-10 22:33:50 -04:00
Keenan Brock bc679817b6 consolidate ActiveRecord 'was' constants 2019-09-10 22:20:15 -04:00
Keenan Brock 758e27b9b9 remove unused path_ids
sorry - I had suggested this to dmu, but it was not used
2019-09-10 22:17:50 -04:00
Keenan Brock 0bf2bb2bd2 Use DELIMITER constant in materialized path 2019-09-10 22:17:44 -04:00
Keenan Brock 3620c0e3df
Merge pull request #458 from kbrock/ancestor_ids_2
Update ancestor_ids not ancestor_column
2019-09-10 17:16:38 -04:00
Keenan Brock f943e4a426 Update ancestor_ids not ancestor_column
all but one reference are updating the ancestor_ids column

This is a moot point to be honest, behind the scenes, it is just
updating the ancestors field in the database, but this gives us
some indirection so we can change the ancestor encoding scheme
2019-09-10 10:51:20 -04:00
Keenan Brock e7b2283184
Merge pull request #455 from kbrock/unconditional
Move conditionals to MaterializedPath
2019-09-09 21:21:19 -04:00
Keenan Brock b0d44767aa
Merge pull request #263 from kbrock/create-child-in-after-callback-2
Fix creating children in after_* callbacks
2019-09-09 16:54:25 -04:00
Jason Stirk f94b22ba1b Fix creating children in after_* callbacks
Previously creating children in an after_* callback would cause the
child's ancestry column to contain just the parent id and not the entire
ancestry path.

A workaround was to call self.reload in the after_* callback, but this
commit makes the process work automatically.

The main issue looked to be that the child_ancestry method was using the
ancestry path before the save (using _was) which for new records was
obviously blank.

This revision uses the current value of the parent's ancestry, and adds
a child_ancestry_was method to return the old behaviour (with a more
descriptive name).

The change to update_descendants_with_new_ancestry was due to it relying
on the old behaviour. The revised version explicitly replaces the old
parent ancestry snippet (using child_ancestry_was) with the new one
path.

REVISED for 2.1.x version of ancestry
2019-09-09 16:50:23 -04:00
Keenan Brock beea5b75af move general scopes to materialized path
removing conditions methods

instead, directly implementing the methods.

descendant_conditions is still hanging around for a little bit
2019-09-09 16:47:13 -04:00
Keenan Brock 3f0b4cd0bf use class scopes instead of instance conditions
This logic is currently a redirect to the class level condition methods
anyway. So removing the indirection and just calling the class
methods directly

The class methods are defined by the scheme (e.g.: materialized path)

unscoped is making descendant_conditions tricky to remove
2019-09-09 16:47:13 -04:00
Keenan Brock b9393f1907
Merge pull request #457 from kbrock/parent_id
call parent id parent_id
2019-09-09 16:44:04 -04:00
Keenan Brock 54a4047595 call parent id parent_id
`parent` used to hold the node's `parent`. so it was called `parent`.

But now it holds the parent id.
So this PR renames the variable to ... `parent_id`

This section of code is too complicated to add the extra cognitive load
and have a confusing variable name

thanks @nicklamuro
2019-09-09 16:42:34 -04:00
Keenan Brock ab7d7590cd
Merge pull request #456 from kbrock/was_was_before_save
Stop using was
2019-09-09 16:35:52 -04:00
Keenan Brock a2597ba6ee proper use of path_ids_was 2019-09-09 16:30:59 -04:00
Keenan Brock e926876df5 make update_descendant more readable 2019-09-09 16:17:37 -04:00
Keenan Brock b449ed360d
Merge pull request #453 from d-m-u/object_creation_performance_enhancements
Performance enhancements for minimizing object creation
2019-09-08 17:04:14 -04:00
d-m-u 44e6a2313c
performance enhancements for minimizing object creation 2019-09-07 18:50:57 -04:00
Keenan Brock 3e333879bc
Merge pull request #452 from kbrock/nil_parent
tests to ensure parent.children.create works
2019-09-05 21:34:44 -04:00
Keenan Brock 8864eca801 tests to ensure parent.children.create works 2019-09-05 21:33:34 -04:00
Denny Mueller 11411f5040 use id in find instead of object 2019-09-05 21:26:49 -04:00
Keenan Brock c9ae6f14a3
Merge pull request #451 from kbrock/better_sanity
fix :primary_key_format
2019-09-05 21:01:46 -04:00
Keenan Brock a52697ba63 allow developer to specify :primary_key_format
it gets rid of a constant
it moves all the validation to one spot.

I'm thinking different strategies will have different schemes

I liked having it defined in materialized path, but wanted to get rid
of the constant more
2019-09-05 20:49:40 -04:00
Keenan Brock 6effcac3da use validation to validate ancestry field pattern 2019-09-05 20:00:33 -04:00
Keenan Brock 717aae48c2
Merge pull request #383 from kbrock/ancestry_ids
use ancestor_ids instead of string munging
2019-09-05 19:42:09 -04:00
Keenan Brock b20c98667e use delimiter and parse_ancestry_column
now that methods are moved over to materialized path, use
the common methods
2019-09-05 19:40:43 -04:00
Keenan Brock c194b92084 move path methods to path class 2019-09-05 19:40:15 -04:00
Keenan Brock 29752c35e5 use ancestor_ids 2019-09-05 19:28:33 -04:00
Keenan Brock 3d3d3c9aab
Merge pull request #450 from kbrock/rails_6_major
update rails versions 6.0 and 5.1.7
2019-09-05 19:24:04 -04:00
Keenan Brock 4ebd552392 update rails versions 6.0 and 5.1.7 2019-09-05 19:23:18 -04:00
Keenan Brock f6a3e65107
Merge pull request #447 from AllanKlaus/fix-split-on-fixnum
Fix error when ancestry field is integer
2019-07-01 13:24:26 -04:00
Allan Klaus 7a83b6981d Fix error when ancestry field is integer
- Problem
When the field field ancestry is an integer on database the method
`parse_ancestry_column` raise error because of split is not a method
of integer

- Solution
Return the method `to_s` on the method `parse_ancestry_column` to change
integer to string before do the split

- Error Log

```
NoMethodError:
        undefined method `split' for 13654:Fixnum
      # /home/klaus/.rvm/gems/ruby-2.3.1/gems/ancestry-3.0.7/lib/ancestry/instance_methods.rb:381:in `parse_ancestry_column'
      # /home/klaus/.rvm/gems/ruby-2.3.1/gems/ancestry-3.0.7/lib/ancestry/instance_methods.rb:153:in `ancestor_ids'
```

- Issue: #446
2019-06-25 11:52:23 -03:00
David Staehler 90e7b3ca76 Fix update_all deprecations 2019-06-10 16:12:01 -04:00
Keenan Brock 2180aa19d9
Merge pull request #445 from kbrock/peg_sqlite3
peg active sqlite3 for earlier versions of ar
2019-06-10 16:07:47 -04:00