activerecord-bitemporal-tablize 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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a31b7fe58c46784c45f3620b873bbd5a69e00ef41799505c1d3b5b361a446458
|
4
|
+
data.tar.gz: bf4f8847a18a5dec5b18a2f75a8f6ec824dea6a2fa532b445e47df227ad87f7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 753493508c1d7ed7e7218f47b075e53124df60c6f255cc74934078acaf1fc831b52d69033b2715d8aa45154c2372acaaad882f2440a76fac042736c9c2eaf508
|
7
|
+
data.tar.gz: 99a0984a0c5bd06be2097bb816f2452494f5bf82c7d381d87dad5df8922005d4f4d7c6257e8862e7c174ec45b6b52a6c39d219f13174fe17a5423b0c7c9355f2
|
data/README.md
CHANGED
@@ -23,10 +23,11 @@ Or install it yourself as:
|
|
23
23
|
## Usage
|
24
24
|
|
25
25
|
ローカル環境でgemをインストールし、`rails console`した後でrequireする
|
26
|
+
|
26
27
|
ref: https://qiita.com/kyanny/items/d370efe14ef15d9afacb
|
27
28
|
|
28
29
|
```
|
29
|
-
[1] pry(main)> Employee.first.
|
30
|
+
[1] pry(main)> Employee.first.histories.print_table
|
30
31
|
(0.8ms) SELECT sqlite_version(*)
|
31
32
|
Employee Load (0.3ms) SELECT "employees".* FROM "employees" WHERE "employees"."valid_from" <= ? AND "employees"."valid_to" > ? AND "employees"."deleted_at" IS NULL ORDER BY "employees"."bitemporal_id" ASC LIMIT ? [["valid_from", "2021-06-20 13:21:42.229006"], ["valid_to", "2021-06-20 13:21:42.229006"], ["LIMIT", 1]]
|
32
33
|
Employee Load (0.2ms) SELECT "employees".* FROM "employees" WHERE "employees"."deleted_at" IS NULL AND "employees"."bitemporal_id" = ? ORDER BY "employees"."valid_from" DESC [["bitemporal_id", 1]]
|
@@ -39,7 +40,7 @@ ref: https://qiita.com/kyanny/items/d370efe14ef15d9afacb
|
|
39
40
|
| | 1 | 1 | たけし | | 2021-06-20 01:44:43 UTC | 2021-06-20 01:44:43 UTC | 1 | 2020/01/01 | 2021/04/01 | | 2021-06-20 01:44:43 UTC | 9999-12-31 00:00:00 UTC |
|
40
41
|
+-2020/01/01-+----+---------+--------+-----------+-------------------------+-------------------------+---------------+------------+------------+------------+-------------------------+-------------------------+
|
41
42
|
=> nil
|
42
|
-
[2] pry(main)> Employee.first.
|
43
|
+
[2] pry(main)> Employee.first.histories.print_table_diff_only
|
43
44
|
Employee Load (0.2ms) SELECT "employees".* FROM "employees" WHERE "employees"."valid_from" <= ? AND "employees"."valid_to" > ? AND "employees"."deleted_at" IS NULL ORDER BY "employees"."bitemporal_id" ASC LIMIT ? [["valid_from", "2021-06-20 13:21:44.302316"], ["valid_to", "2021-06-20 13:21:44.302316"], ["LIMIT", 1]]
|
44
45
|
Employee Load (0.1ms) SELECT "employees".* FROM "employees" WHERE "employees"."deleted_at" IS NULL AND "employees"."bitemporal_id" = ? ORDER BY "employees"."valid_from" DESC [["bitemporal_id", 1]]
|
45
46
|
+------------+---------+--------+-------------------------+------------+------------+
|
@@ -51,7 +52,7 @@ ref: https://qiita.com/kyanny/items/d370efe14ef15d9afacb
|
|
51
52
|
| | 1 | たけし | 2021-06-20 01:44:43 UTC | 2020/01/01 | 2021/04/01 |
|
52
53
|
+-2020/01/01-+---------+--------+-------------------------+------------+------------+
|
53
54
|
=> nil
|
54
|
-
[3] pry(main)> Employee.first.
|
55
|
+
[3] pry(main)> Employee.first.histories.print_table(:name)
|
55
56
|
Employee Load (0.2ms) SELECT "employees".* FROM "employees" WHERE "employees"."valid_from" <= ? AND "employees"."valid_to" > ? AND "employees"."deleted_at" IS NULL ORDER BY "employees"."bitemporal_id" ASC LIMIT ? [["valid_from", "2021-06-20 13:22:54.269095"], ["valid_to", "2021-06-20 13:22:54.269095"], ["LIMIT", 1]]
|
56
57
|
Employee Load (0.1ms) SELECT "employees".* FROM "employees" WHERE "employees"."deleted_at" IS NULL AND "employees"."bitemporal_id" = ? ORDER BY "employees"."valid_from" DESC [["bitemporal_id", 1]]
|
57
58
|
+------------+--------+
|
@@ -2,8 +2,12 @@ module ActiveRecord
|
|
2
2
|
module Bitemporal
|
3
3
|
module Bitemporalize
|
4
4
|
module InstanceMethods
|
5
|
-
def
|
6
|
-
records =
|
5
|
+
def histories
|
6
|
+
records = begin
|
7
|
+
super
|
8
|
+
rescue NoMethodError
|
9
|
+
self.class.ignore_valid_datetime.bitemporal_for(bitemporal_id).order(valid_from: :desc)
|
10
|
+
end
|
7
11
|
|
8
12
|
records.define_singleton_method(:print_table) do |*attributes|
|
9
13
|
print ActiveRecord::Bitemporal::Tablize.new(records: records, attributes: attributes).call
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-bitemporal-tablize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lighty
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06-
|
11
|
+
date: 2021-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Displaying the history of records managed by ActiveRecord::Bitemporal
|
14
14
|
in a tabular format.
|