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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 76f3628c85ded9452a6825695726c6814153051c3345812f6e411f447b9114fb
4
- data.tar.gz: 04bca1e6301d41a901e73432ad98b062e508a40e0156fa8a803e0c3fdb765f2d
3
+ metadata.gz: 75110dd7aeb5c0972a2f4a2bc018133627b3322b6491bbb491b0f395306cc8ec
4
+ data.tar.gz: 2e882c3d2373d7accc19c7b1efc9cc74f690d76bec9693145f358ae436706d31
5
5
  SHA512:
6
- metadata.gz: 2133d07d50f683647d055aaf877169dadbd62bde6cde8bab24ed785e660c99f844ff80c2be0cd2f3bfec30ec8fba9d902d3ca85ef8dd877f89b54bfd1580d59c
7
- data.tar.gz: 8c14320fbeaf09ca1a789f7c4232e5908849ede96b645b13a8f12a1922e07902f700a8c6ae36221d47f485d15a72be1f499789a58f4c0a62e4219ee94a65347c
6
+ metadata.gz: 1f4ba9afdf6edb3afca680e9f3df7e9e0a16d650c5dcd2419c7784683d89fe10425b681d12228b504ad6652354bcf776cf4bd53d111ccbd3978c061d2f1ea34d
7
+ data.tar.gz: 3d079a8442eb89134f27c26e65cd86825e850392fa98d85b130992910fe56126b42dbce30be4adeb5b6d3bca4ad7765321c8122ebcc4ceb3a294d6f2007a01e1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## master (unreleased)
2
2
 
3
+ ## 0.1.1 (2022-11-26)
4
+
5
+ - Do not prematurely load `ActiveRecord::Base`
6
+
7
+ See https://github.com/rails/rails/issues/46567 for details.
8
+
3
9
  ## 0.1.0 (2022-04-21)
4
10
 
5
11
  - First release
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 help you to schedule some verifications on your data and get alerts when something is unexpected.
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.joins(:previews).having("COUNT(*) < 3").group(:attachment_id)
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DataChecks
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
data/lib/data_checks.rb CHANGED
@@ -1,20 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "data_checks/check_run"
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.0
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-04-21 00:00:00.000000000 Z
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.3.7
83
+ rubygems_version: 3.1.6
70
84
  signing_key:
71
85
  specification_version: 4
72
86
  summary: Regression testing for data