indexes 4.0.0.1 → 4.0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a85cfb89d3f21e21f193faf2441da4b69f58e0bb
4
- data.tar.gz: f8f9fb65b28caf68ccf2729e501154f467bfd771
3
+ metadata.gz: 759bf9d8c97099c9d2fa84417fe4a867accc60a0
4
+ data.tar.gz: 0c4fcea3a9e464f342cf5e6c1816a8b4eceffae1
5
5
  SHA512:
6
- metadata.gz: e364f9186bacba3601d4d72051b4ff3a1d8e606e934d492e151564e5c214b9fe04a3675d66a6aed08018989ba905dfb61ba79b2faf08475921f955b1d63ebfa5
7
- data.tar.gz: 14b8a8c999ccd47088d69ebadd0086dc7d2f800d8aac45c2829bdda382bc7269c5b730a4d2af76cb51be6d7af2a9d7ae619badd252c2b8a755b8621de578c256
6
+ metadata.gz: 55e7fbbe47f9a988b7c9fe2a6a63d7e41b2e883594573e767838a1db0984108c6714f35d5e822973e11326dd4b2205756c52c573badde464a49af37c26e1a0a9
7
+ data.tar.gz: d97fdd8db8faf71494e09472effbdd096bb0ae3e91b159fe676a068833a71922c31ab033655eee096b263b8d948cf8716dd6dcd99fa19c7b7752f7db1ea31551
data/README.md CHANGED
@@ -14,7 +14,7 @@ I did this gem to:
14
14
  - Gain control of the queries without losing simplicity.
15
15
  - Have out of the box integration with activerecord and pagers.
16
16
  - Deal with the just in time nature of elasticsearch.
17
- - Reduce queries by integrating activerecord eager loaders.
17
+ - Integrate activerecord includes on it.
18
18
  - Have a convention of how to use suggestions.
19
19
 
20
20
  ## Install
@@ -32,7 +32,7 @@ module Indexes
32
32
  when String,Symbol
33
33
  child = {}
34
34
  node = { args.first.to_sym => child }
35
- when Enumerable
35
+ when Enumerable,ActiveRecord::Relation
36
36
  child = node = []
37
37
  else
38
38
  child = node = {}
@@ -44,7 +44,7 @@ module Indexes
44
44
  @parent[name] = node
45
45
  end
46
46
  case args.first
47
- when Enumerable
47
+ when Enumerable,ActiveRecord::Relation
48
48
  args.first.each do |arg|
49
49
  self.class.new [arg], child, &block
50
50
  end
data/lib/indexes/index.rb CHANGED
@@ -137,11 +137,9 @@ module Indexes
137
137
 
138
138
  def indexify_model
139
139
  index = self
140
- model.class_eval do
141
- include Indexes::Concern
142
- define_singleton_method :index do
143
- index
144
- end
140
+ model.include Indexes::Concern
141
+ model.define_singleton_method :index do
142
+ index
145
143
  end
146
144
  end
147
145
 
@@ -1,5 +1,5 @@
1
1
  module Indexes
2
2
 
3
- VERSION = '4.0.0.1'
3
+ VERSION = '4.0.0.2'
4
4
 
5
5
  end
@@ -3459,3 +3459,185 @@ SearchTest: test_with_and_without
3459
3459
  Shop Load (0.5ms) SELECT "shops".* FROM "shops" WHERE "shops"."id" IN (4, 3)
3460
3460
  Shop Load (0.5ms) SELECT "shops".* FROM "shops" WHERE "shops"."id" IN (2, 1)
3461
3461
   (0.8ms) ROLLBACK
3462
+ ActiveRecord::SchemaMigration Load (12.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
3463
+  (0.2ms) BEGIN
3464
+ --------------------
3465
+ IndexTest: test_find
3466
+ --------------------
3467
+ Product Load (1.7ms) SELECT "products".* FROM "products" ORDER BY "products"."id" ASC LIMIT 1000
3468
+ Shop Load (0.4ms) SELECT "shops".* FROM "shops" ORDER BY "shops"."id" ASC LIMIT 1000
3469
+  (0.3ms) ROLLBACK
3470
+  (0.1ms) BEGIN
3471
+ ---------------------
3472
+ IndexTest: test_exist
3473
+ ---------------------
3474
+ Product Load (0.7ms) SELECT "products".* FROM "products" ORDER BY "products"."id" ASC LIMIT 1000
3475
+ Shop Load (0.3ms) SELECT "shops".* FROM "shops" ORDER BY "shops"."id" ASC LIMIT 1000
3476
+  (0.3ms) ROLLBACK
3477
+  (0.1ms) BEGIN
3478
+ -------------------------
3479
+ IndexTest: test_namespace
3480
+ -------------------------
3481
+ Product Load (0.3ms) SELECT "products".* FROM "products" ORDER BY "products"."id" ASC LIMIT 1000
3482
+ Shop Load (0.4ms) SELECT "shops".* FROM "shops" ORDER BY "shops"."id" ASC LIMIT 1000
3483
+  (0.3ms) ROLLBACK
3484
+  (0.1ms) BEGIN
3485
+ -----------------------
3486
+ IndexTest: test_suggest
3487
+ -----------------------
3488
+ Product Load (0.3ms) SELECT "products".* FROM "products" ORDER BY "products"."id" ASC LIMIT 1000
3489
+ Shop Load (0.4ms) SELECT "shops".* FROM "shops" ORDER BY "shops"."id" ASC LIMIT 1000
3490
+  (0.2ms) SAVEPOINT active_record_1
3491
+ SQL (0.4ms) INSERT INTO "shops" ("created_at", "updated_at") VALUES ($1, $2) RETURNING "id" [["created_at", "2016-12-08 07:17:51.865747"], ["updated_at", "2016-12-08 07:17:51.865747"]]
3492
+  (0.2ms) RELEASE SAVEPOINT active_record_1
3493
+  (0.3ms) SAVEPOINT active_record_1
3494
+ SQL (0.4ms) INSERT INTO "products" ("name", "shop_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id" [["name", "Les Paul"], ["shop_id", 91], ["created_at", "2016-12-08 07:17:51.884909"], ["updated_at", "2016-12-08 07:17:51.884909"]]
3495
+  (0.2ms) RELEASE SAVEPOINT active_record_1
3496
+  (0.2ms) SAVEPOINT active_record_1
3497
+ SQL (0.2ms) INSERT INTO "products" ("name", "shop_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id" [["name", "Stratocaster"], ["shop_id", 91], ["created_at", "2016-12-08 07:17:51.908797"], ["updated_at", "2016-12-08 07:17:51.908797"]]
3498
+  (0.2ms) RELEASE SAVEPOINT active_record_1
3499
+  (0.4ms) ROLLBACK
3500
+  (0.1ms) BEGIN
3501
+ ----------------------
3502
+ SearchTest: test_order
3503
+ ----------------------
3504
+ Product Load (2.0ms) SELECT "products".* FROM "products" ORDER BY "products"."id" ASC LIMIT 1000
3505
+ Shop Load (0.4ms) SELECT "shops".* FROM "shops" ORDER BY "shops"."id" ASC LIMIT 1000
3506
+  (0.1ms) SAVEPOINT active_record_1
3507
+ SQL (0.3ms) INSERT INTO "shops" ("created_at", "updated_at") VALUES ($1, $2) RETURNING "id" [["created_at", "2016-12-08 07:17:53.970899"], ["updated_at", "2016-12-08 07:17:53.970899"]]
3508
+  (0.3ms) RELEASE SAVEPOINT active_record_1
3509
+  (0.1ms) SAVEPOINT active_record_1
3510
+ SQL (0.2ms) INSERT INTO "products" ("id", "name", "price", "position", "currency", "shop_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING "id" [["id", 1], ["name", "1"], ["price", 1], ["position", 1], ["currency", "UYU"], ["shop_id", 92], ["created_at", "2016-12-08 07:17:53.977620"], ["updated_at", "2016-12-08 07:17:53.977620"]]
3511
+  (0.1ms) RELEASE SAVEPOINT active_record_1
3512
+  (0.3ms) SAVEPOINT active_record_1
3513
+ SQL (0.3ms) INSERT INTO "products" ("id", "name", "price", "position", "currency", "shop_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING "id" [["id", 2], ["name", "2"], ["price", 2], ["position", 2], ["currency", "UYU"], ["shop_id", 92], ["created_at", "2016-12-08 07:17:53.985363"], ["updated_at", "2016-12-08 07:17:53.985363"]]
3514
+  (0.2ms) RELEASE SAVEPOINT active_record_1
3515
+  (0.5ms) SAVEPOINT active_record_1
3516
+ SQL (0.3ms) INSERT INTO "products" ("id", "name", "price", "position", "currency", "shop_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING "id" [["id", 3], ["name", "3"], ["price", 3], ["position", 3], ["currency", "UYU"], ["shop_id", 92], ["created_at", "2016-12-08 07:17:54.000285"], ["updated_at", "2016-12-08 07:17:54.000285"]]
3517
+  (0.2ms) RELEASE SAVEPOINT active_record_1
3518
+ Product Load (0.4ms) SELECT "products".* FROM "products" WHERE "products"."id" IN (1, 2, 3)
3519
+ Product Load (0.3ms) SELECT "products".* FROM "products" WHERE "products"."id" IN (3, 2, 1)
3520
+ Product Load (0.4ms) SELECT "products".* FROM "products" WHERE "products"."id" IN (1, 2, 3)
3521
+ Product Load (0.4ms) SELECT "products".* FROM "products" WHERE "products"."id" IN (3, 2, 1)
3522
+ Product Load (0.4ms) SELECT "products".* FROM "products" WHERE "products"."id" IN (1, 2, 3)
3523
+ Product Load (0.4ms) SELECT "products".* FROM "products" WHERE "products"."id" IN (3, 2, 1)
3524
+ Product Load (0.4ms) SELECT "products".* FROM "products" WHERE "products"."id" IN (3, 2, 1)
3525
+ Product Load (0.3ms) SELECT "products".* FROM "products" WHERE "products"."id" IN (3, 2, 1)
3526
+  (0.3ms) ROLLBACK
3527
+  (0.2ms) BEGIN
3528
+ ---------------------------------
3529
+ SearchTest: test_with_and_without
3530
+ ---------------------------------
3531
+ Product Load (0.3ms) SELECT "products".* FROM "products" ORDER BY "products"."id" ASC LIMIT 1000
3532
+ Shop Load (0.3ms) SELECT "shops".* FROM "shops" ORDER BY "shops"."id" ASC LIMIT 1000
3533
+  (0.1ms) SAVEPOINT active_record_1
3534
+ SQL (0.2ms) INSERT INTO "shops" ("id", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["id", 1], ["created_at", "2016-12-08 07:17:56.109461"], ["updated_at", "2016-12-08 07:17:56.109461"]]
3535
+  (0.2ms) RELEASE SAVEPOINT active_record_1
3536
+  (0.2ms) SAVEPOINT active_record_1
3537
+ SQL (0.2ms) INSERT INTO "shops" ("id", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["id", 2], ["created_at", "2016-12-08 07:17:56.114552"], ["updated_at", "2016-12-08 07:17:56.114552"]]
3538
+  (0.1ms) RELEASE SAVEPOINT active_record_1
3539
+  (0.2ms) SAVEPOINT active_record_1
3540
+ SQL (0.2ms) INSERT INTO "shops" ("id", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["id", 3], ["created_at", "2016-12-08 07:17:56.119549"], ["updated_at", "2016-12-08 07:17:56.119549"]]
3541
+  (0.1ms) RELEASE SAVEPOINT active_record_1
3542
+  (0.2ms) SAVEPOINT active_record_1
3543
+ SQL (0.2ms) INSERT INTO "shops" ("id", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["id", 4], ["created_at", "2016-12-08 07:17:56.124166"], ["updated_at", "2016-12-08 07:17:56.124166"]]
3544
+  (0.1ms) RELEASE SAVEPOINT active_record_1
3545
+ Shop Load (0.3ms) SELECT "shops".* FROM "shops" WHERE "shops"."id" IN (4, 3)
3546
+ Shop Load (0.3ms) SELECT "shops".* FROM "shops" WHERE "shops"."id" IN (2, 1)
3547
+  (0.3ms) ROLLBACK
3548
+  (0.1ms) BEGIN
3549
+ -------------------------
3550
+ SearchTest: test_includes
3551
+ -------------------------
3552
+ Product Load (0.3ms) SELECT "products".* FROM "products" ORDER BY "products"."id" ASC LIMIT 1000
3553
+ Shop Load (0.4ms) SELECT "shops".* FROM "shops" ORDER BY "shops"."id" ASC LIMIT 1000
3554
+  (0.1ms) SAVEPOINT active_record_1
3555
+ SQL (0.2ms) INSERT INTO "shops" ("created_at", "updated_at") VALUES ($1, $2) RETURNING "id" [["created_at", "2016-12-08 07:17:58.186957"], ["updated_at", "2016-12-08 07:17:58.186957"]]
3556
+  (0.2ms) RELEASE SAVEPOINT active_record_1
3557
+  (0.1ms) SAVEPOINT active_record_1
3558
+ SQL (0.2ms) INSERT INTO "products" ("name", "shop_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id" [["name", "Test"], ["shop_id", 93], ["created_at", "2016-12-08 07:17:58.189261"], ["updated_at", "2016-12-08 07:17:58.189261"]]
3559
+  (0.2ms) RELEASE SAVEPOINT active_record_1
3560
+ Product Load (0.3ms) SELECT "products".* FROM "products" WHERE "products"."id" = 82
3561
+ Shop Load (0.3ms) SELECT "shops".* FROM "shops" WHERE "shops"."id" IN (93)
3562
+  (0.3ms) ROLLBACK
3563
+  (0.1ms) BEGIN
3564
+ ---------------------------
3565
+ SearchTest: test_pagination
3566
+ ---------------------------
3567
+ Product Load (0.3ms) SELECT "products".* FROM "products" ORDER BY "products"."id" ASC LIMIT 1000
3568
+ Shop Load (0.3ms) SELECT "shops".* FROM "shops" ORDER BY "shops"."id" ASC LIMIT 1000
3569
+  (0.2ms) SAVEPOINT active_record_1
3570
+ SQL (0.2ms) INSERT INTO "shops" ("id", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["id", 1], ["created_at", "2016-12-08 07:18:00.260816"], ["updated_at", "2016-12-08 07:18:00.260816"]]
3571
+  (0.2ms) RELEASE SAVEPOINT active_record_1
3572
+  (0.2ms) SAVEPOINT active_record_1
3573
+ SQL (0.2ms) INSERT INTO "shops" ("id", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["id", 2], ["created_at", "2016-12-08 07:18:00.266911"], ["updated_at", "2016-12-08 07:18:00.266911"]]
3574
+  (0.1ms) RELEASE SAVEPOINT active_record_1
3575
+  (0.3ms) SAVEPOINT active_record_1
3576
+ SQL (0.2ms) INSERT INTO "shops" ("id", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["id", 3], ["created_at", "2016-12-08 07:18:00.273222"], ["updated_at", "2016-12-08 07:18:00.273222"]]
3577
+  (0.2ms) RELEASE SAVEPOINT active_record_1
3578
+  (0.2ms) SAVEPOINT active_record_1
3579
+ SQL (0.2ms) INSERT INTO "shops" ("id", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["id", 4], ["created_at", "2016-12-08 07:18:00.279674"], ["updated_at", "2016-12-08 07:18:00.279674"]]
3580
+  (0.2ms) RELEASE SAVEPOINT active_record_1
3581
+  (0.2ms) SAVEPOINT active_record_1
3582
+ SQL (0.2ms) INSERT INTO "shops" ("id", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["id", 5], ["created_at", "2016-12-08 07:18:00.284510"], ["updated_at", "2016-12-08 07:18:00.284510"]]
3583
+  (0.1ms) RELEASE SAVEPOINT active_record_1
3584
+ Shop Load (0.7ms) SELECT "shops".* FROM "shops" WHERE "shops"."id" IN (5, 4)
3585
+ Shop Load (0.5ms) SELECT "shops".* FROM "shops" WHERE "shops"."id" IN (3, 2)
3586
+ Shop Load (0.9ms) SELECT "shops".* FROM "shops" WHERE "shops"."id" = 1
3587
+ Shop Load (0.4ms) SELECT "shops".* FROM "shops" WHERE 1=0
3588
+ Shop Load (0.3ms) SELECT "shops".* FROM "shops" WHERE "shops"."id" IN (3, 2)
3589
+ Shop Load (0.9ms) SELECT "shops".* FROM "shops" WHERE "shops"."id" = 1
3590
+ Shop Load (0.4ms) SELECT "shops".* FROM "shops" WHERE 1=0
3591
+  (0.4ms) ROLLBACK
3592
+  (0.2ms) BEGIN
3593
+ -------------------------
3594
+ RecordTest: test_indexing
3595
+ -------------------------
3596
+ Product Load (0.5ms) SELECT "products".* FROM "products" ORDER BY "products"."id" ASC LIMIT 1000
3597
+ Shop Load (0.6ms) SELECT "shops".* FROM "shops" ORDER BY "shops"."id" ASC LIMIT 1000
3598
+  (0.2ms) SAVEPOINT active_record_1
3599
+ SQL (0.2ms) INSERT INTO "shops" ("name", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["name", "Anderstons"], ["created_at", "2016-12-08 07:18:02.422517"], ["updated_at", "2016-12-08 07:18:02.422517"]]
3600
+  (0.1ms) RELEASE SAVEPOINT active_record_1
3601
+  (0.1ms) SAVEPOINT active_record_1
3602
+ SQL (0.2ms) INSERT INTO "products" ("name", "category", "shop_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["name", "Les Paul"], ["category", "Gibson"], ["shop_id", 94], ["created_at", "2016-12-08 07:18:02.425929"], ["updated_at", "2016-12-08 07:18:02.425929"]]
3603
+  (0.2ms) RELEASE SAVEPOINT active_record_1
3604
+ Product Load (0.3ms) SELECT "products".* FROM "products" WHERE "products"."id" = 83
3605
+  (0.1ms) SAVEPOINT active_record_1
3606
+ SQL (0.2ms) DELETE FROM "products" WHERE "products"."id" = $1 [["id", 83]]
3607
+  (0.1ms) RELEASE SAVEPOINT active_record_1
3608
+ Product Load (0.3ms) SELECT "products".* FROM "products" WHERE "products"."id" = 83
3609
+  (0.4ms) ROLLBACK
3610
+  (0.2ms) BEGIN
3611
+ --------------------
3612
+ DslTest: test_search
3613
+ --------------------
3614
+  (0.1ms) SAVEPOINT active_record_1
3615
+ SQL (0.2ms) INSERT INTO "shops" ("created_at", "updated_at") VALUES ($1, $2) RETURNING "id" [["created_at", "2016-12-08 07:18:04.468747"], ["updated_at", "2016-12-08 07:18:04.468747"]]
3616
+  (0.1ms) RELEASE SAVEPOINT active_record_1
3617
+  (0.2ms) ROLLBACK
3618
+  (0.1ms) BEGIN
3619
+ ---------------------------
3620
+ GeneratorTest: test_install
3621
+ ---------------------------
3622
+  (0.1ms) ROLLBACK
3623
+  (0.1ms) BEGIN
3624
+ -------------------------
3625
+ GeneratorTest: test_index
3626
+ -------------------------
3627
+  (0.2ms) ROLLBACK
3628
+  (0.1ms) BEGIN
3629
+ --------------------
3630
+ TaskTest: test_build
3631
+ --------------------
3632
+ Product Load (0.8ms) SELECT "products".* FROM "products" ORDER BY "products"."id" ASC LIMIT 1000
3633
+ Shop Load (0.3ms) SELECT "shops".* FROM "shops" ORDER BY "shops"."id" ASC LIMIT 1000
3634
+  (0.4ms) ROLLBACK
3635
+  (0.1ms) BEGIN
3636
+ ----------------------
3637
+ TaskTest: test_rebuild
3638
+ ----------------------
3639
+ Product Load (0.3ms) SELECT "products".* FROM "products" ORDER BY "products"."id" ASC LIMIT 1000
3640
+ Shop Load (0.3ms) SELECT "shops".* FROM "shops" ORDER BY "shops"."id" ASC LIMIT 1000
3641
+ Product Load (0.4ms) SELECT "products".* FROM "products" ORDER BY "products"."id" ASC LIMIT 1000
3642
+ Shop Load (0.3ms) SELECT "shops".* FROM "shops" ORDER BY "shops"."id" ASC LIMIT 1000
3643
+  (0.3ms) ROLLBACK
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: indexes
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.1
4
+ version: 4.0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - mmontossi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-06 00:00:00.000000000 Z
11
+ date: 2016-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails