fact_metrics 0.1.0 → 0.1.1

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: 77dd1df505a65d11950bc95d193a7812d3814d421c79c02fba3537e289fe3034
4
- data.tar.gz: 3ec05a41dbcabfca15a2655bba69bc9afea6b0496e4887e83da8b683e99c0338
3
+ metadata.gz: aef2ccf770bcfdf80825f10cfd3bb72200fb057decb14f26da336b61bd9a6071
4
+ data.tar.gz: 7eaf22066fa953e1227784f4aaf36a5377bbd84f5bcbc2928ab0f7c01ac064fc
5
5
  SHA512:
6
- metadata.gz: 47b7f36271813d46ceb7255387c8ad7e861d78457891dabdf2d13ec8233bbb631bacae9d24bbde447b1d6851cc7bf13eb8a2d4318940d6292c4928831b639e8e
7
- data.tar.gz: b8d7c5096bd94f3b185903f21b285c80430600a590be5a77c47c429e02cbe7434da26b83d76c8f639e7ef6bf913fdc72cb3ac2b34d6453a1a8911fb4b1ce84bd
6
+ metadata.gz: 393a516d4d635ae4e119e46ac348491c9aac10279a9deef2b5772abb2af8bd254c98d4deb676fcf7bd509520c25fed852e21e22cc5c986d090bfa669ba262e2d
7
+ data.tar.gz: a05f5940ecbecce896d419c938ee6db85f0e2c2999e691f75d218b5fbf7c48e28f6dd77bc959962957832c082c0cfa32ae3a6c7e9baea30b749f241cf984cef2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
- ## [Unreleased]
1
+ ## [0.1.1] - 2025-01-07
2
2
 
3
- ## [0.1.0] - 2024-12-09
3
+ - Update percentage SQL to use ANSI standard decimal casting.
4
+
5
+ ## [0.1.0] - 2024-12-31
4
6
 
5
7
  - Initial release
data/README.md CHANGED
@@ -5,18 +5,16 @@ models.
5
5
 
6
6
  ## Installation
7
7
 
8
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
9
-
10
8
  Install the gem and add to the application's Gemfile by executing:
11
9
 
12
10
  ```bash
13
- bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
11
+ bundle add fact_metrics
14
12
  ```
15
13
 
16
14
  If bundler is not being used to manage dependencies, install the gem by executing:
17
15
 
18
16
  ```bash
19
- gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
17
+ gem install fact_metrics
20
18
  ```
21
19
 
22
20
  ## Usage
@@ -42,6 +40,22 @@ In your Fact model you can add the following types of metric definitions.
42
40
  percentage :inspected, field: quantity_inspected, condition: "> 0"
43
41
  ```
44
42
 
43
+ ### Accessing metrics
44
+
45
+ Depending on your needs, you can either calculate all of the metrics, or a
46
+ subset. If your Fact model defines a large number of metrics specifying a subset
47
+ of them can often improve performance.
48
+
49
+ To get all available metrics:
50
+ ```
51
+ Fact::Sales.all_metrics
52
+ ```
53
+
54
+ To get only sales_quantity_count:
55
+ ```
56
+ Fact::Sales.load_metrics(:sales_quantity_counts)
57
+ ```
58
+
45
59
  ## Development
46
60
 
47
61
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  module FactMetrics::Count
4
2
  extend ActiveSupport::Concern
5
3
 
@@ -24,7 +24,7 @@ class FactMetrics::PercentageConfig
24
24
  <<~SQL
25
25
  ROUND(
26
26
  (
27
- (COUNT(*) FILTER (WHERE #{condition_sql}))::decimal
27
+ CAST(COUNT(*) FILTER (WHERE #{condition_sql}) AS DECIMAL)
28
28
  /
29
29
  NULLIF(#{denominator_sql}, 0)
30
30
  ) * 100,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FactMetrics
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fact_metrics
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
  - Scott Maslar
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-12-31 00:00:00.000000000 Z
11
+ date: 2025-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -52,7 +52,7 @@ licenses:
52
52
  - MIT
53
53
  metadata:
54
54
  homepage_uri: https://github.com/PatchMonkeyHQ/fact_metrics
55
- source_code_uri: https://github.com/PatchMonkeyHQ/fact_metric
55
+ source_code_uri: https://github.com/PatchMonkeyHQ/fact_metrics
56
56
  changelog_uri: https://github.com/PatchMonkeyHQ/fact_metrics/blob/main/CHANGELOG.md
57
57
  post_install_message:
58
58
  rdoc_options: []