data_checks 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +19 -2
- data/lib/data_checks/status_printer.rb +2 -2
- data/lib/data_checks/version.rb +1 -1
- data/lib/data_checks.rb +15 -11
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75110dd7aeb5c0972a2f4a2bc018133627b3322b6491bbb491b0f395306cc8ec
|
4
|
+
data.tar.gz: 2e882c3d2373d7accc19c7b1efc9cc74f690d76bec9693145f358ae436706d31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f4ba9afdf6edb3afca680e9f3df7e9e0a16d650c5dcd2419c7784683d89fe10425b681d12228b504ad6652354bcf776cf4bd53d111ccbd3978c061d2f1ea34d
|
7
|
+
data.tar.gz: 3d079a8442eb89134f27c26e65cd86825e850392fa98d85b130992910fe56126b42dbce30be4adeb5b6d3bca4ad7765321c8122ebcc4ceb3a294d6f2007a01e1
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
This gem provides a small DSL to check your data for inconsistencies and anomalies.
|
4
4
|
|
5
|
+
[![Build Status](https://github.com/fatkodima/data_checks/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/fatkodima/data_checks/actions/workflows/test.yml)
|
6
|
+
|
5
7
|
## Installation
|
6
8
|
|
7
9
|
Add this line to your application's Gemfile:
|
@@ -23,7 +25,15 @@ You could also assume that your data will never get corrupted, and validations d
|
|
23
25
|
|
24
26
|
This gem doesn't aim to replace those tools, but provides something else that could serve a close purpose: *ensure that you work with the data you expect*.
|
25
27
|
|
26
|
-
This gem
|
28
|
+
This gem helps you to schedule some verifications on your data and get alerts when something is unexpected.
|
29
|
+
|
30
|
+
`data_checks` can help to catch:
|
31
|
+
|
32
|
+
* 🐛 **Bugs due to race conditions** (e.g. user accidentally double clicks a button to delete an email and ends up without emails due to a race condition bug in the app)
|
33
|
+
* 🐛 **Invalid persisted data**
|
34
|
+
* 🐛 **Unexpected changes in behavior and data** (e.g. too many (too less) of something is created/deleted/imported/enqueued/..., etc)
|
35
|
+
|
36
|
+
This idea is nicely presented at RailsConf: [RailsConf 2018: The Doctor Is In: Using checkups to find bugs in production by Ryan Laughlin](https://www.youtube.com/watch?v=gEAlhKaK2I4)
|
27
37
|
|
28
38
|
## Usage
|
29
39
|
|
@@ -37,8 +47,15 @@ For example, we expect every image attachment to have previews in 3 sizes. It is
|
|
37
47
|
|
38
48
|
```ruby
|
39
49
|
DataChecks.configure do
|
50
|
+
ensure_no :users_without_emails, tag: "minutely" do
|
51
|
+
User.where.missing(:email_addresses)
|
52
|
+
end
|
53
|
+
|
40
54
|
ensure_no :images_without_previews, tag: "hourly" do
|
41
|
-
Attachment.images
|
55
|
+
Attachment.images
|
56
|
+
.left_joins(:previews)
|
57
|
+
.group(:attachment_id)
|
58
|
+
.having("COUNT(previews.id) < 3")
|
42
59
|
end
|
43
60
|
|
44
61
|
notifier :email,
|
@@ -31,8 +31,8 @@ module DataChecks
|
|
31
31
|
private
|
32
32
|
def print_summary(counts)
|
33
33
|
statuses = DataChecks::CheckRun.statuses
|
34
|
-
summary = "Error: #{counts[statuses[:error]]}, "\
|
35
|
-
"Failing: #{counts[statuses[:failing]]}, "\
|
34
|
+
summary = "Error: #{counts[statuses[:error]]}, " \
|
35
|
+
"Failing: #{counts[statuses[:failing]]}, " \
|
36
36
|
"Passing: #{counts[statuses[:passing]]}"
|
37
37
|
summary += ", Not Ran: #{counts['not_ran']}" if counts["not_ran"] > 0
|
38
38
|
@io.puts(summary)
|
data/lib/data_checks/version.rb
CHANGED
data/lib/data_checks.rb
CHANGED
@@ -1,20 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
4
|
-
require "data_checks/check_result"
|
5
|
-
require "data_checks/check"
|
6
|
-
require "data_checks/ensure_less"
|
7
|
-
require "data_checks/ensure_more"
|
8
|
-
require "data_checks/ensure_no"
|
9
|
-
require "data_checks/notifiers"
|
10
|
-
require "data_checks/config"
|
11
|
-
require "data_checks/runner"
|
12
|
-
require "data_checks/status_printer"
|
13
|
-
require "data_checks/version"
|
3
|
+
require "active_record"
|
14
4
|
|
5
|
+
require "data_checks/version"
|
15
6
|
require "data_checks/railtie" if defined?(Rails)
|
16
7
|
|
17
8
|
module DataChecks
|
9
|
+
extend ActiveSupport::Autoload
|
10
|
+
|
11
|
+
autoload :Check
|
12
|
+
autoload :CheckResult
|
13
|
+
autoload :CheckRun
|
14
|
+
autoload :Config
|
15
|
+
autoload :EnsureLess
|
16
|
+
autoload :EnsureMore
|
17
|
+
autoload :EnsureNo
|
18
|
+
autoload :Notifiers
|
19
|
+
autoload :Runner
|
20
|
+
autoload :StatusPrinter
|
21
|
+
|
18
22
|
class << self
|
19
23
|
def config
|
20
24
|
@config ||= Config.new
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: data_checks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fatkodima
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
12
|
-
dependencies:
|
11
|
+
date: 2022-11-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activerecord
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.2'
|
13
27
|
description:
|
14
28
|
email:
|
15
29
|
- fatkodima123@gmail.com
|
@@ -66,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
80
|
- !ruby/object:Gem::Version
|
67
81
|
version: '0'
|
68
82
|
requirements: []
|
69
|
-
rubygems_version: 3.
|
83
|
+
rubygems_version: 3.1.6
|
70
84
|
signing_key:
|
71
85
|
specification_version: 4
|
72
86
|
summary: Regression testing for data
|