janela 0.16.1 → 0.16.2

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: 720d124c207d9183b7450a7be6597adc0593b3addb26cc548cd2e445b828f250
4
- data.tar.gz: db09ec1528a8b2b75c2369ae1e8d537b515e314416f01cd0e2463cdafab9d64b
3
+ metadata.gz: f90ccaae7d4191d3b5bfa3db12db772656808a9b15908d73bef299beda109eef
4
+ data.tar.gz: a3cd040d84114900904349d9bde09ad89fb264624a7997c3a9961e9947f8b266
5
5
  SHA512:
6
- metadata.gz: 9497ce5bb01d59a4e43006bca8c3243ce162c0b5ea760011c58921791acf43df2932785c89d5bc99a7eb62c113b4a53e5fce3a7c983395ac410571fd439e26db
7
- data.tar.gz: 9f7bcad7c5cbbed3523960fc0f0db1c045fabd8b02e41e1f2bed357a9dad000a6dfaeae9eee02c716acd7e5b65018dff14bfba257e19e5450ee3d302e1b20ac6
6
+ metadata.gz: 6cdcc597e34ed611a8c9c2f448875ca9e5cd487f888b5bed8fe0c1e9f5e22728ad6f3b743da7c3b868b80b85a0c6565630e6604629fbe7d316c5d00a338213cb
7
+ data.tar.gz: 0a96deb8421cc49ce7048cfe148ef2516fd2edd4bb91b24635ec172935db2d728ae4e3be871abfb346a6870b577b854505057909d35cabdfed7737e49ad722c4
data/CHANGELOG.md CHANGED
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.16.2] - 2026-11-23
9
+
10
+ ### Fixed
11
+
12
+ - **A value-labelled ratio's axis ends where the data does, not at 120%.** `value_labels` made room for the label above the tallest bar by adding 10% of grace to the value axis, so a ratio whose largest group was 95% drew an axis to 120%, a share no bar can reach. A ratio's labels now get their room from padding above the plot, so the axis ends at 100% (or wherever the data does). Every other measure keeps the grace, which also leaves room under a negative bar, and draws what it did (#96, ADR 054).
13
+ - **A pane is narrowed by a click on a dimension whose name starts with its own.** A pane sets aside the reader's filter on its own dimension, so the pane you clicked shows the alternatives. It recognised that filter by prefix, so a pane by `store` also set aside `store_type_in` and drew every store, unfiltered, after a click on a store type. Pairs like `category` and `category_group`, or `region` and `region_manager`, met the same thing. Only a key that is exactly the pane's own dimension and a Ransack predicate is set aside now. One visible difference: a misspelt predicate on the pane's own dimension (`store_inn` on a pane by store), which was quietly set aside with it, is now refused like a typo on any other key (#103, ADR 003, ADR 025).
14
+ - **A misspelt predicate on a key reached through an association is refused, not dropped, on a pane that ignores unknown filters.** On a pane with `ignore_unknown_filters`, `customer_region_inn` (a typo for `customer_region_in`) was dropped as if it belonged to another model, and the pane drew an unfiltered number with no error. A plain column with the same typo (`status_inn`) was already refused. A key reached through an association is now held to the same rule: refused with its reason when it starts with a dimension the model declares and ends with no predicate Ransack knows. Another model's key that only shares the prefix, such as `customer_region_code_in`, is still dropped (#94, ADR 063).
15
+
8
16
  ## [0.16.1] - 2026-11-02
9
17
 
10
18
  ### Added
@@ -326,6 +334,7 @@ First alpha, installed from GitHub for testing in a single host application.
326
334
  - Only models that declare a `janela` block are addressable over HTTP.
327
335
  - ADRs 001 to 004 in `docs/decisions/`, shipped inside the gem.
328
336
 
337
+ [0.16.2]: https://github.com/retail-tasker/janela/releases/tag/v0.16.2
329
338
  [0.16.1]: https://github.com/retail-tasker/janela/releases/tag/v0.16.1
330
339
  [0.16.0]: https://github.com/retail-tasker/janela/releases/tag/v0.16.0
331
340
  [0.15.0]: https://github.com/retail-tasker/janela/releases/tag/v0.15.0
data/README.md CHANGED
@@ -390,7 +390,7 @@ A host with no tenancy defines nothing, gets a nil owner, and is correct: nothin
390
390
 
391
391
  The dashboard's filters live in the page URL as the same `q[...]` parameters, so a reload keeps them and a filtered dashboard is a link you can send: `/reports/orders?q[status_in][]=paid` renders filtered before any JavaScript runs. A pane ignores filters on its own dimension, so clicking a value re-scopes the rest of the dashboard rather than collapsing the pane you clicked. Clicking a bucket on a time pane filters the others to the range it covers. Every selected value is marked `aria-pressed="true"` on tables and drawn solid against faded siblings on charts, so it can be styled and read.
392
392
 
393
- **A frame over two models.** Every pane is handed the frame's filters, and a pane refuses a key its model does not declare, because Ransack would otherwise drop it and show an unfiltered number (ADR 025). On a frame that holds panes over two models that refusal reaches a click it should not: `paid` clicked on an orders pane is `q[status_in][]=paid` to a page views pane, which has no status and would answer "That request is not allowed on this pane" where its number was. A pane can say it ignores what it cannot apply: `janela_pane PageView, :views, by: :page, ignore_unknown_filters: true`, or the checkbox on the pane form, or `?ignore_unknown_filters=1` in the pane URL. The keys Ransack would drop are dropped before the query, a key the model does declare is applied as on any pane, a declared key with a predicate the dimension does not allow is still refused, and a host's `where:` and a frame's `default_where` are still refused when wrong. Unset, a pane is what it always was, so a typo on a pane that never meets another model still fails loudly. Two models share a click only when they spell the key the same, which for a dimension reached through an association is `<association>_<column>` (ADR 063).
393
+ **A frame over two models.** Every pane is handed the frame's filters, and a pane refuses a key its model does not declare, because Ransack would otherwise drop it and show an unfiltered number (ADR 025). On a frame that holds panes over two models that refusal reaches a click it should not: `paid` clicked on an orders pane is `q[status_in][]=paid` to a page views pane, which has no status and would answer "That request is not allowed on this pane" where its number was. A pane can say it ignores what it cannot apply: `janela_pane PageView, :views, by: :page, ignore_unknown_filters: true`, or the checkbox on the pane form, or `?ignore_unknown_filters=1` in the pane URL. The keys Ransack would drop are dropped before the query, a key the model does declare is applied as on any pane, a declared key with a predicate the dimension does not allow is still refused, including one reached through an association, and a host's `where:` and a frame's `default_where` are still refused when wrong. Unset, a pane is what it always was, so a typo on a pane that never meets another model still fails loudly. Two models share a click only when they spell the key the same, which for a dimension reached through an association is `<association>_<column>` (ADR 063).
394
394
 
395
395
  **Selecting more than one.** Ctrl or Cmd click adds a value to the selection and takes it out again, leaving the rest alone, which is how every list in every operating system already behaves. A plain click selects one value and replaces whatever was selected, or clears the dimension if that value was the only one. It works the same on a chart. The (none) group, the rows that have nothing there, is a member of the selection like any value: Ctrl or Cmd click it beside a value and the panes show the rows that have that value or nothing (`q[channel_in][]=web&q[channel_null]=1`), where `not_in` and `not_null` together still mean neither (ADR 049). All of it works from the keyboard too: a value is a real `<button>`, so Enter is a click and Ctrl or Cmd with Enter adds. `Escape` clears the frame's filters, and those are the only two keys Janela binds, both only while focus is inside the frame, because a single letter belongs to your application and to any text field on the page (ADR 024). A pane with no matching rows renders a `.janela-empty` paragraph. A group whose dimension is null is labelled `(none)` and filters with Ransack's null predicate rather than an empty string. Only models that declare a `janela` block can be requested over HTTP.
396
396
 
@@ -581,7 +581,7 @@ Deliberately out of scope: natural-language query, a separate data warehouse, a
581
581
 
582
582
  ## Status
583
583
 
584
- **v0.16.1 alpha.** The measures/dimensions DSL, time dimensions, cross-filtering with multi-selection, bar, line, doughnut and pie charts, pane URLs, shareable dashboard URLs, snapshots, database-backed frames found by owner and key, panes that hold words or a host partial as well as a query, a host-fixed filter no click can remove and a frame's own permanent one beside it, STI subclasses, the engine's own pages for reading and editing them, bar charts that read in their measure's format and can show each bar's value, category panes that can be ordered either way by their measure or by their label, tools an agent can use to read and arrange a dashboard, and the optional vitral theme work and are covered by unit and real-browser tests, with the classes a theme may target documented in [Theming Janela](docs/theming.md). Not yet built: a visual editor, and narrowing a time pane's own granularity by clicking one of its buckets (a click on a bucket does filter the others). [Vista](docs/roadmap.md), the roadmap, says what 1.0 means and which of these are in it; open work is in [GitHub Issues](https://github.com/retail-tasker/janela/issues).
584
+ **v0.16.2 alpha.** The measures/dimensions DSL, time dimensions, cross-filtering with multi-selection, bar, line, doughnut and pie charts, pane URLs, shareable dashboard URLs, snapshots, database-backed frames found by owner and key, panes that hold words or a host partial as well as a query, a host-fixed filter no click can remove and a frame's own permanent one beside it, STI subclasses, the engine's own pages for reading and editing them, bar charts that read in their measure's format and can show each bar's value, category panes that can be ordered either way by their measure or by their label, tools an agent can use to read and arrange a dashboard, and the optional vitral theme work and are covered by unit and real-browser tests, with the classes a theme may target documented in [Theming Janela](docs/theming.md). Not yet built: a visual editor, and narrowing a time pane's own granularity by clicking one of its buckets (a click on a bucket does filter the others). [Vista](docs/roadmap.md), the roadmap, says what 1.0 means and which of these are in it; open work is in [GitHub Issues](https://github.com/retail-tasker/janela/issues).
585
585
 
586
586
  ## Development
587
587
 
@@ -35,6 +35,7 @@ export default class extends Controller {
35
35
  // is decided here, when the chart is made: patched onto a chart built
36
36
  // with it on, it draws at the wrong size.
37
37
  maintainAspectRatio: !this.fixedHeightValue,
38
+ layout: this.labelRoomAbove() ? { padding: { top: Chart.defaults.font.size + 8 } } : undefined,
38
39
  scales: this.scales(),
39
40
  // A line is clicked anywhere along its x position rather than on
40
41
  // the exact pixel of a point, which on a dense series is a few
@@ -125,7 +126,7 @@ export default class extends Controller {
125
126
  const scales = { y: {
126
127
  beginAtZero: true,
127
128
  // Room above the tallest bar, and below the lowest, for its label (ADR 054).
128
- grace: this.valueLabelsValue ? "10%" : undefined,
129
+ grace: this.valueLabelsValue && !this.labelRoomAbove() ? "10%" : undefined,
129
130
  title: this.axisTitle(this.axesValue.left),
130
131
  ticks
131
132
  } }
@@ -146,6 +147,14 @@ export default class extends Controller {
146
147
  return scales
147
148
  }
148
149
 
150
+ // A ratio's labels get their room from padding above the plot rather than
151
+ // from grace on the scale, which took a share of 95% to an axis of 120%
152
+ // (#96). A ratio is never negative, so nothing is needed below. Other
153
+ // measures keep the grace, which also leaves room under a negative bar.
154
+ labelRoomAbove() {
155
+ return this.valueLabelsValue && this.tickFormatValue.ratio === true
156
+ }
157
+
149
158
  axisTitle(text) {
150
159
  return text ? { display: true, text } : undefined
151
160
  }
@@ -657,7 +657,7 @@ module Janela
657
657
  def applicable_filters
658
658
  @applicable_filters ||= begin
659
659
  given = ignore_unknown_filters ? definition.applicable(filters) : filters
660
- single_value? ? given : given.reject { |key, _| key.to_s.start_with?(ransack_name) }
660
+ single_value? ? given : given.reject { |key, _| dimension_definition.key?(key) }
661
661
  end
662
662
  end
663
663
  end
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  Date: 2026-10-29
3
- Status: Proposed
3
+ Status: Accepted
4
4
  Related: ADR 002, ADR 005, ADR 006, ADR 007, ADR 009, ADR 018, ADR 020, ADR 029, ADR 037, ADR 045, ADR 046, ADR 047, ADR 051, ADR 054, ADR 055
5
5
  Triggers:
6
6
  - a running total, a cumulative line, a to-date figure over time
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  Date: 2026-10-29
3
- Status: Proposed
3
+ Status: Accepted
4
4
  Related: ADR 003, ADR 005, ADR 008, ADR 012, ADR 025, ADR 035, ADR 037, ADR 040, ADR 043, ADR 053
5
5
  Triggers:
6
6
  - a frame holding panes over more than one model
@@ -0,0 +1,146 @@
1
+ ---
2
+ Date: 2026-11-20
3
+ Status: Proposed
4
+ Related: ADR 002, ADR 007, ADR 009, ADR 020, ADR 038, ADR 054, ADR 055, ADR 062
5
+ Triggers:
6
+ - adding a measure kind, or a sixth aggregate to the DSL
7
+ - counting distinct values rather than rows
8
+ - dividing one sum by another, or a rate against a target
9
+ - hiding or dashing a value worked out from too few rows
10
+ - a ratio that can be above 100%
11
+ Topics: DSL, query layer, measures, formatting, ordering
12
+ ---
13
+
14
+ # ADR 064: A Measure Can Count Distinct Values, Divide Two Sums, and Require a Minimum of Rows
15
+
16
+ ## Context
17
+
18
+ #97, from a host building reporting frames over fact views. A measure
19
+ today is one of five aggregates, or `ratio:` of one boolean column
20
+ (ADR 038). Three things a reporting page needs cannot be declared:
21
+
22
+ - **A count of distinct values.** "Stores visited" is not "visits".
23
+ - **One sum over another.** Visits against target, or ranged lines against
24
+ lines expected. It reads as a percentage, and it can rightly be above
25
+ 100%: a store that beat its target did not make an error.
26
+ - **A minimum sample.** A ratio over three rows is noise that looks like a
27
+ finding. The host's own rule is fifty observations before a rate is
28
+ shown.
29
+
30
+ Measured against the demo on `3a41a64` (Rails main, SQLite), with
31
+ `Order` grouped by `status`:
32
+
33
+ - `relation.distinct.count(:customer_id)` answers a hash per group,
34
+ through Groupdate per month too, and its grouped alias is
35
+ `count_customer_id`, the same alias ADR 007 already orders a count by.
36
+ Nothing new is needed for grouping, ordering or gap filling.
37
+ - A ratio of two sums cannot be one `relation.<aggregate>(expression)`
38
+ call: `SUM(a) / SUM(b)` is not an argument to any one aggregate, and
39
+ wrapping it nests aggregates. Two sums read separately and divided per
40
+ key are right, and Groupdate fills both with zero, so an empty bucket is
41
+ `0 / 0`, which has to be no value rather than an error. Ordering by the
42
+ expression itself, `SUM(a) * 1.0 / NULLIF(SUM(b), 0)`, works in an
43
+ `ORDER BY` beside a `GROUP BY`, which is how ADR 038 already orders a
44
+ ratio.
45
+ - `HAVING COUNT(*) >= 2` on a category pane returns only the groups that
46
+ qualify, before `limit`. On a time pane the same `HAVING` through
47
+ Groupdate returned `{}` where every day had one row: Groupdate fills
48
+ between the first and last bucket it is given, so with none it draws
49
+ nothing, and with some it draws a shorter axis. A minimum on a time
50
+ pane cannot be a `HAVING`.
51
+
52
+ ### What was considered
53
+
54
+ **A free SQL expression measure** (`measure :x, sql: "..."`) would cover
55
+ all three and every future ask. Rejected: it is a second query language
56
+ beside Ransack (ADR 001, ADR 002), it cannot be checked at declaration,
57
+ and a forker reading it learns nothing about what it means.
58
+
59
+ **A ratio of sums as a new key, `divide: [:a, :b]`.** Rejected for the
60
+ name. A boolean ratio already is a division, the true rows over the known
61
+ rows, and reading the two as one idea with one name is simpler than two
62
+ words for it.
63
+
64
+ **`min_rows` drawing a dash in a category pane.** A table row reading
65
+ "–" was the first shape asked for. Rejected for how it meets `limit` and
66
+ `sort`: on `sort: :asc, limit: 10`, the bottom ten would be chosen from
67
+ groups that include the suppressed ones, so either the dashes take the
68
+ places of real values or they are sorted out of the limit and never seen
69
+ anyway. Leaving them out before the limit is the version that answers the
70
+ question a bottom ten asks.
71
+
72
+ **Clamping a ratio of sums at 100%.** Rejected. Over 100% is a real
73
+ answer, and a clamped one is a wrong number that looks right.
74
+
75
+ ## Decision
76
+
77
+ **A measure can be `count_distinct:` a column, `ratio:` one column `over:`
78
+ another, and any measure that does not add up can require `min_rows:`.**
79
+
80
+ ```ruby
81
+ janela do
82
+ measure :visits, count: true
83
+ measure :stores_visited, count_distinct: :place_id
84
+ measure :to_target, ratio: :visits, over: :target
85
+ measure :in_stock_rate, ratio: :in_stock, min_rows: 50
86
+ end
87
+ ```
88
+
89
+ **`count_distinct:`** is `COUNT(DISTINCT column)`, a sixth aggregate. It
90
+ reads as a count (no decimal places, ADR 020) and orders by its count
91
+ alias. It is not additive: two months' distinct stores do not sum to the
92
+ quarter's, so `cumulative` refuses it as it refuses an average (ADR 062),
93
+ and a bucket with no rows is zero.
94
+
95
+ **`ratio: :a, over: :b`** is `SUM(a) / SUM(b)`, read by two sums and
96
+ divided per group. Both columns must be numeric, checked at declaration
97
+ the way ADR 038 checks a boolean. Without `over:`, `ratio:` is what it
98
+ is today. It is stored as the fraction and read as a percentage, exactly
99
+ as ADR 038 says, and is never clamped: 1.25 reads `125.0%`, and the
100
+ axis follows the data (#96). A group whose denominator sums to zero has
101
+ no value, as an empty bucket of a boolean ratio has none today. It
102
+ orders by the expression. It does not add up, so `cumulative` refuses it.
103
+
104
+ **`min_rows:`** is a whole number of rows a group needs before its value
105
+ is shown. It is allowed on an average, a minimum, a maximum and either
106
+ ratio, and refused on a sum, a count or a count distinct, which are
107
+ true however few rows they are over. Rows are the group's rows after
108
+ every filter, `COUNT(*)`.
109
+
110
+ - On a category pane a group under the minimum is **left out before**
111
+ `sort` and `limit`, as `HAVING COUNT(*) >= n`, so a bottom ten is ten
112
+ groups that qualified.
113
+ - On a time pane, a series (ADR 062) and a single value, a bucket under
114
+ the minimum **has no value**: read beside a count of its rows and set to
115
+ none after the read, so the axis is the same with or without it. It is
116
+ a gap on a line, no bar, and `–` in a table or a single value.
117
+ - A snapshot stores what the query returned, so a frozen value under the
118
+ minimum stays without one (ADR 009).
119
+
120
+ **No pane or URL changes.** All three are declarations on the model, the
121
+ same way every measure option is (ADR 020). A stored pane names the
122
+ measure and gets them.
123
+
124
+ ## Consequences
125
+
126
+ - A reporting host can declare the three it asked for without a view per
127
+ question or a second model.
128
+ - `Measure` grows from five aggregates and a ratio to six and a ratio
129
+ with an optional denominator, plus one option. `Definition#query` reads
130
+ a ratio of sums in two queries, and a time pane with `min_rows` in two.
131
+ Both are bounded: the second query has the same `GROUP BY` as the first.
132
+ - A category pane with `min_rows` can show fewer rows than its `limit`
133
+ with nothing on the page saying why. That is the honest cost of leaving
134
+ groups out. A note under the pane saying how many were left out is a
135
+ later question, not decided here.
136
+ - **`–` for no value.** Today an empty bucket of a ratio formats as an
137
+ empty string. A suppressed value and an empty one should read the same,
138
+ so both become `–`. That is a visible change to every host with a ratio
139
+ over empty buckets, small, and listed in the changelog.
140
+ - `Janela::Tools` and `describe_vocabulary` need nothing new: they list
141
+ measures by name (ADR 053).
142
+ - What would change this decision: a host needing a running ratio of
143
+ sums, which is meaningful (the running numerator over the running
144
+ denominator) and could be allowed later without changing these names;
145
+ or one needing the left-out groups listed, which would argue for the
146
+ dash again.
@@ -0,0 +1,123 @@
1
+ ---
2
+ Date: 2026-11-20
3
+ Status: Proposed
4
+ Related: ADR 002, ADR 003, ADR 020, ADR 025, ADR 040, ADR 043, ADR 051, ADR 062, ADR 064
5
+ Triggers:
6
+ - narrowing one pane without narrowing the frame around it
7
+ - two panes over the same model where only one is filtered
8
+ - a measure of only some rows, such as new products or one channel
9
+ - adding a where to a pane, or a filter column to janela_panes
10
+ Topics: DSL, query layer, measures, cross-filtering, frames
11
+ ---
12
+
13
+ # ADR 065: A Measure Can Carry Its Own Condition, So One Pane Is Narrowed and Not the Frame
14
+
15
+ ## Context
16
+
17
+ #98. Every narrowing a host can apply today is frame-wide. A host's
18
+ `where:` (ADR 040) narrows every pane a `janela_frame` draws, and a
19
+ frame's `default_where` (ADR 043) narrows every pane over its model. A
20
+ frame cannot hold "sales" beside "sales of new products" over the same
21
+ model. The only way today is a second model or a second database view per
22
+ condition, which turns a one-word difference into a schema change.
23
+
24
+ Read against the code on `ced8ea9`: `Definition#query` and
25
+ `Definition#series` both start from `filter(on || model.all, where)`, and
26
+ `Definition#narrow` already applies a fixed set of Ransack conditions
27
+ under ADR 025's bounds (declared dimensions, allowed predicates, the value
28
+ limit), raising with its reason. A condition has one obvious place to go
29
+ in: the relation, before the grouping, in the two methods every pane
30
+ passes through.
31
+
32
+ ### What was considered
33
+
34
+ **A `where:` on the pane.** The obvious reading of "fix a filter on one
35
+ pane". Rejected for its cost and for what it says. It is a new column on
36
+ `janela_panes`, a new parameter in the pane URL (ADR 037 counts both as
37
+ public surface), a field on the pane form and an attribute in
38
+ `Janela::Tools`, and it has to be told how it composes with the reader's
39
+ `q[...]` on the same key. And it puts the meaning in the wrong place:
40
+ "sales of new products" is a thing being measured, which a host names once
41
+ on the model, not a property of where a pane happens to sit. Two pages
42
+ wanting it would each write it again.
43
+
44
+ **A `filter:` beside the frame's `where:` that names a pane.** Rejected:
45
+ a hand-written frame has no pane identities to name, and a stored one
46
+ would need its own column anyway.
47
+
48
+ **A conditional aggregate in SQL**, `SUM(CASE WHEN ... THEN x END)`.
49
+ Rejected: Ransack builds `WHERE` conditions, not `CASE` expressions, so
50
+ this would be a second condition language beside Ransack's, which ADR 002
51
+ exists to avoid. It would also keep every group in a category pane with a
52
+ zero where it has no matching rows, which reads as a measured zero rather
53
+ than an absence.
54
+
55
+ ## Decision
56
+
57
+ **A measure may carry `where:`, a hash of Ransack conditions on the
58
+ model's declared dimensions, and it measures only the rows that meet
59
+ them.**
60
+
61
+ ```ruby
62
+ janela do
63
+ measure :sales, sum: :amount
64
+ measure :new_product_sales, sum: :amount, where: { new_product_eq: true }
65
+ measure :online_orders, count: true, where: { channel_in: %w[web app] }
66
+
67
+ dimension :new_product
68
+ dimension :channel
69
+ end
70
+ ```
71
+
72
+ ```erb
73
+ <%= janela_frame do %>
74
+ <%= janela_pane Sale, :sales, by: :region, as: :bar %>
75
+ <%= janela_pane Sale, :new_product_sales, by: :region, as: :bar %>
76
+ <% end %>
77
+ ```
78
+
79
+ **It is applied as one more narrowing, before the grouping,** through
80
+ `Definition#narrow`, in `query` and `series`. So it composes with every
81
+ other narrowing the same way they compose with each other: a frame's
82
+ default, a host's `where:`, the reader's selection and the measure's own
83
+ condition are all ANDed. A reader's click that contradicts it (`no` on
84
+ `new_product` for a pane of new product sales) leaves that pane empty,
85
+ which is the true answer to the question asked.
86
+
87
+ **It is checked when the `janela` block ends,** against the dimensions the
88
+ block declared and ADR 025's predicate bounds, and a wrong condition raises
89
+ at boot with the same sentence a bad request would get. The check waits for
90
+ the end of the block because a measure is usually declared before the
91
+ dimensions it names.
92
+
93
+ **It travels with the measure.** A pane, a series (ADR 062), a stored
94
+ pane, a snapshot, a companion column's facts (ADR 051) and
95
+ `Janela::Tools` name the measure and get its condition. Nothing about a
96
+ pane, its URL or its form changes.
97
+
98
+ **A pane's own dimension is not exempt.** A measure narrowed to two
99
+ channels drawn `by: :channel` shows those two. The cross-filtering rule
100
+ (ADR 003) sets aside the reader's selection on a pane's own dimension;
101
+ the measure's condition is part of what the pane measures, not a
102
+ selection.
103
+
104
+ ## Consequences
105
+
106
+ - A frame can hold a measure and a narrowed version of it side by side
107
+ with no new model, view or pane setting.
108
+ - A category pane of a narrowed measure shows only groups that have
109
+ matching rows, not every group with a zero. A host wanting every group
110
+ listed puts the unnarrowed measure beside it.
111
+ - The condition is the host's own code, read at boot, so it is not part
112
+ of ADR 025's request bounds in the sense of arriving over HTTP. It is
113
+ still held to them, because a typo in it would otherwise be a silently
114
+ unfiltered measure, the failure this library is built to refuse.
115
+ - The measure's name is the only label a reader sees, so it has to say
116
+ what is narrowed ("New product sales", not "Sales 2"). That is the
117
+ host's naming, as it is for every measure (ADR 020).
118
+ - Works with ADR 064's measures unchanged: a ratio over a condition is a
119
+ ratio of the rows that meet it, and `min_rows` counts those rows.
120
+ - What would change this decision: a host needing the narrowing chosen
121
+ per page rather than per measure, such as an analyst picking a filter
122
+ for one stored pane at run time. That is a pane-level `where:`, and it
123
+ would need its own ADR on the URL and the form.
@@ -22,12 +22,12 @@ them when in doubt: `grep -l "Triggers:.*fork" docs/decisions/*.md`.
22
22
  |-------|------|
23
23
  | **Vision, scope, forkability** | 001, 010, 012, 037, 052 |
24
24
  | **Open-source & host-decoupling** | 001, 022, 036, 041, 052, 060, 061 |
25
- | **DSL & query layer** | 002, 006, 007, 020, 025, 038, 044, 049, 051, 055, 062 |
25
+ | **DSL & query layer** | 002, 006, 007, 020, 025, 038, 044, 049, 051, 055, 062, 064, 065 |
26
26
  | **Dependencies** | 002, 003, 004, 006, 017, 025, 053 |
27
27
  | **Authorisation** | 002, 003, 004, 009, 017, 019, 022, 032, 033, 034, 035, 039, 040, 048, 053 |
28
28
  | **Performance & storage** | 007, 017, 025, 048, 051 |
29
- | **Ordering & formatting** | 007, 020, 038, 054, 055, 061, 062 |
30
- | **Cross-filtering & Hotwire** | 003, 004, 005, 008, 024, 025, 040, 043, 044, 045, 048, 049, 063 |
29
+ | **Ordering & formatting** | 007, 020, 038, 054, 055, 061, 062, 064 |
30
+ | **Cross-filtering & Hotwire** | 003, 004, 005, 008, 024, 025, 040, 043, 044, 045, 048, 049, 063, 065 |
31
31
  | **Layouts & views** | 011, 012, 016, 018, 020, 027, 039, 047, 050, 059 |
32
32
  | **CSS & styling** | 016, 018, 023, 026, 027, 036, 042, 046, 047, 050, 062 |
33
33
  | **Frames, panes & persistence** | 012, 013, 014, 019, 029, 030, 033, 039, 040, 041, 043, 044, 047, 048, 050, 051, 053, 054, 055, 062, 063 |
@@ -109,9 +109,11 @@ them when in doubt: `grep -l "Triggers:.*fork" docs/decisions/*.md`.
109
109
  | 059 | A Host Can Tell Janela's Own Pages That Its Layout Draws Charts | 2026-10-14 | Proposed |
110
110
  | 060 | The Demo Tells Search Engines What It Is, and Shows Its Own Adoption | 2026-10-14 | Proposed |
111
111
  | 061 | The Demo Speaks Brazilian Portuguese Under a Prefix, and the Gem Stays English | 2026-10-14 | Proposed |
112
- | 062 | A Time Pane Can Accumulate, and Carry More Series on Two Axes | 2026-10-29 | Proposed |
113
- | 063 | A Pane Can Ignore a Filter Its Model Cannot Apply | 2026-10-29 | Proposed |
112
+ | 062 | A Time Pane Can Accumulate, and Carry More Series on Two Axes | 2026-10-29 | Accepted |
113
+ | 063 | A Pane Can Ignore a Filter Its Model Cannot Apply | 2026-10-29 | Accepted |
114
+ | 064 | A Measure Can Count Distinct Values, Divide Two Sums, and Require a Minimum of Rows | 2026-11-20 | Proposed |
115
+ | 065 | A Measure Can Carry Its Own Condition, So One Pane Is Narrowed and Not the Frame | 2026-11-20 | Proposed |
114
116
 
115
117
  ## Next number
116
118
 
117
- Next ADR: 064
119
+ Next ADR: 066
@@ -272,9 +272,11 @@ module Janela
272
272
 
273
273
  # A key Ransack did not apply that is a declared dimension and a suffix
274
274
  # that is not another attribute with a known predicate on it: path_inn is
275
- # path with a typo, status_code_in is a different attribute entirely.
275
+ # path with a typo, status_code_in is a different attribute entirely. A
276
+ # dimension through an association is spelt <association>_<column> here as
277
+ # everywhere else, so it is held to the same rule (#94).
276
278
  def misspelt_declared_key?(key)
277
- dimensions.values.reject(&:through).any? do |dimension|
279
+ dimensions.values.any? do |dimension|
278
280
  rest = key.to_s.delete_prefix("#{dimension.ransack_name}_")
279
281
  rest != key.to_s && Ransack.predicates.keys.none? { |predicate| rest.end_with?("_#{predicate}") }
280
282
  end
@@ -110,6 +110,14 @@ module Janela
110
110
  through ? "#{through}_#{column}" : column.to_s
111
111
  end
112
112
 
113
+ # Whether a filter key is this dimension's: its Ransack name and then a
114
+ # predicate Ransack knows, exactly. A prefix alone is not enough, since
115
+ # store_type_in starts with store and is another dimension's (#103).
116
+ def key?(key)
117
+ prefix = "#{ransack_name}_"
118
+ key.to_s.start_with?(prefix) && Ransack.predicates.has_key?(key.to_s.delete_prefix(prefix))
119
+ end
120
+
113
121
  def label(bucket, granularity = self.granularity)
114
122
  LABELS.fetch(granularity).call(bucket)
115
123
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Janela
4
- VERSION = "0.16.1"
4
+ VERSION = "0.16.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: janela
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.1
4
+ version: 0.16.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay Killeen
@@ -216,6 +216,8 @@ files:
216
216
  - docs/decisions/061-the-demo-speaks-brazilian-portuguese-under-a-prefix-and-the-gem-stays-english.md
217
217
  - docs/decisions/062-a-time-pane-can-accumulate-and-carry-more-series-on-two-axes.md
218
218
  - docs/decisions/063-a-pane-can-ignore-a-filter-its-model-cannot-apply.md
219
+ - docs/decisions/064-a-measure-can-count-distinct-values-divide-two-sums-and-require-a-minimum-of-rows.md
220
+ - docs/decisions/065-a-measure-can-carry-its-own-condition-so-one-pane-is-narrowed-and-not-the-frame.md
219
221
  - docs/decisions/INDEX.md
220
222
  - docs/multi-tenancy.md
221
223
  - docs/naming.md