reports_kit 0.3.1 → 0.3.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 +4 -4
- data/app/assets/javascripts/reports_kit/lib/report.js +0 -2
- data/config/routes.rb +3 -3
- data/gemfiles/mysql.gemfile.lock +3 -3
- data/gemfiles/postgresql.gemfile.lock +3 -3
- data/lib/reports_kit.rb +5 -2
- data/lib/reports_kit/base_controller.rb +3 -3
- data/lib/reports_kit/configuration.rb +5 -0
- data/lib/reports_kit/filters_controller.rb +9 -0
- data/lib/reports_kit/form_builder.rb +10 -39
- data/lib/reports_kit/helper.rb +3 -13
- data/lib/reports_kit/model_configuration.rb +1 -6
- data/lib/reports_kit/normalized_params.rb +16 -0
- data/lib/reports_kit/report_builder.rb +3 -2
- data/lib/reports_kit/reports/composite_series.rb +4 -3
- data/lib/reports_kit/reports/data/aggregate_composite.rb +1 -1
- data/lib/reports_kit/reports/data/generate_for_properties.rb +1 -1
- data/lib/reports_kit/reports/filter_with_series.rb +4 -0
- data/lib/reports_kit/reports/generate_autocomplete_results.rb +5 -20
- data/lib/reports_kit/reports/inferrable_configuration.rb +1 -1
- data/lib/reports_kit/reports/properties.rb +10 -0
- data/lib/reports_kit/reports/properties_to_filter.rb +40 -0
- data/lib/reports_kit/reports/series.rb +7 -2
- data/lib/reports_kit/reports_controller.rb +1 -15
- data/lib/reports_kit/version.rb +1 -1
- data/spec/factories/pro_repo_factory.rb +5 -0
- data/spec/reports_kit/reports/data/generate_spec.rb +27 -0
- data/spec/spec_helper.rb +4 -3
- data/spec/support/models/pro/repo.rb +5 -0
- data/spec/support/models/pro/special_issue.rb +4 -0
- metadata +9 -33
- data/docs/README.md +0 -8
- data/docs/dimensions.md +0 -110
- data/docs/display_options.md +0 -80
- data/docs/filters.md +0 -216
- data/docs/images/chart_options.png +0 -0
- data/docs/images/dashed_line.png +0 -0
- data/docs/images/demo_area.png +0 -0
- data/docs/images/demo_dashed_line.png +0 -0
- data/docs/images/demo_horizontal_stacked.png +0 -0
- data/docs/images/demo_legend.png +0 -0
- data/docs/images/demo_multiautocomplete.png +0 -0
- data/docs/images/demo_radar.png +0 -0
- data/docs/images/flights_by_carrier.png +0 -0
- data/docs/images/flights_by_carrier_and_flight_at.png +0 -0
- data/docs/images/flights_by_delay.png +0 -0
- data/docs/images/flights_by_flight_at.png +0 -0
- data/docs/images/flights_by_hours_delayed.png +0 -0
- data/docs/images/flights_with_check_box.png +0 -0
- data/docs/images/flights_with_configured_boolean.png +0 -0
- data/docs/images/flights_with_configured_datetime.png +0 -0
- data/docs/images/flights_with_configured_number.png +0 -0
- data/docs/images/flights_with_configured_string.png +0 -0
- data/docs/images/flights_with_date_range.png +0 -0
- data/docs/images/flights_with_filters.png +0 -0
- data/docs/images/flights_with_multi_autocomplete.png +0 -0
- data/docs/images/flights_with_string_filter.png +0 -0
- data/docs/images/horizontal_bar.png +0 -0
- data/docs/images/legend_right.png +0 -0
- data/docs/images/users_by_created_at_with_filter.png +0 -0
- data/docs/measures.md +0 -12
- data/lib/reports_kit/resources_controller.rb +0 -8
data/docs/filters.md
DELETED
@@ -1,216 +0,0 @@
|
|
1
|
-
### Filters
|
2
|
-
|
3
|
-
#### Overview
|
4
|
-
|
5
|
-
A filter is like a SQL `WHERE`: it filters the results to only include results that match a condition. You can use datetime columns, integer columns, string columns, associations, or even define custom filters.
|
6
|
-
|
7
|
-
For example, if the `Flight` model has a `delay` column that's an integer, the chart below will show only flights that have a delay of greater than 15 minutes:
|
8
|
-
|
9
|
-
```yaml
|
10
|
-
measure: flight
|
11
|
-
filters:
|
12
|
-
- key: delay
|
13
|
-
criteria:
|
14
|
-
operator: '>'
|
15
|
-
value: 15
|
16
|
-
dimensions:
|
17
|
-
- carrier
|
18
|
-
```
|
19
|
-
[<img src="images/flights_with_configured_number.png?raw=true" width="500" />](images/flights_with_configured_number.png?raw=true)
|
20
|
-
|
21
|
-
You can also create form controls that the user can use to filter the chart:
|
22
|
-
|
23
|
-
```yaml
|
24
|
-
measure: flight
|
25
|
-
filters:
|
26
|
-
- carrier
|
27
|
-
- carrier_name
|
28
|
-
- is_on_time
|
29
|
-
- flight_at
|
30
|
-
dimensions:
|
31
|
-
- flight_at
|
32
|
-
- carrier
|
33
|
-
```
|
34
|
-
|
35
|
-
In `app/views/my_view.html.haml`, you can use ReportsKit's form helpers to create the controls:
|
36
|
-
```haml
|
37
|
-
= render_report 'filters' do |f|
|
38
|
-
.pull-right
|
39
|
-
= f.date_range :flight_at
|
40
|
-
= f.multi_autocomplete :carrier, scope: 'top', placeholder: 'Carrier...'
|
41
|
-
= f.string_filter :carrier_name, placeholder: 'Carrier name (e.g. Airlines)...', style: 'width: 175px;'
|
42
|
-
.checkbox
|
43
|
-
= label_tag :is_on_time do
|
44
|
-
= f.check_box :is_on_time
|
45
|
-
On time
|
46
|
-
```
|
47
|
-
[<img src="images/flights_with_filters.png?raw=true" width="500" />](images/flights_with_filters.png?raw=true)
|
48
|
-
|
49
|
-
#### Types
|
50
|
-
|
51
|
-
##### Boolean
|
52
|
-
|
53
|
-
Boolean filters can be used on any `boolean` columns, or you can define your own boolean filter (see [Custom Filters](#custom-filters)).
|
54
|
-
|
55
|
-
```yaml
|
56
|
-
measure: flight
|
57
|
-
filters:
|
58
|
-
- key: is_on_time
|
59
|
-
criteria:
|
60
|
-
value: true
|
61
|
-
dimensions:
|
62
|
-
- carrier
|
63
|
-
```
|
64
|
-
[<img src="images/flights_with_configured_boolean.png?raw=true" width="500" />](images/flights_with_configured_boolean.png?raw=true)
|
65
|
-
|
66
|
-
##### Datetime
|
67
|
-
|
68
|
-
Datetime filters can be used on any `datetime` or `timestamp` columns, or you can define your own datetime filter (see [Custom Filters](#custom-filters)).
|
69
|
-
|
70
|
-
```yaml
|
71
|
-
measure: flight
|
72
|
-
filters:
|
73
|
-
- key: flight_at
|
74
|
-
criteria:
|
75
|
-
operator: between
|
76
|
-
value: -3M - now
|
77
|
-
dimensions:
|
78
|
-
- carrier
|
79
|
-
```
|
80
|
-
[<img src="images/flights_with_configured_datetime.png?raw=true" width="500" />](images/flights_with_configured_datetime.png?raw=true)
|
81
|
-
|
82
|
-
The `value` in the example above is shorthand for relative time; it represents the time range of `(3.months.ago..Time.zone.now)`. To see the other supported time durations (e.g. `w` for week, `d` for day), see [RelativeTime](https://github.com/tombenner/reports_kit/blob/master/lib/reports_kit/relative_time.rb).
|
83
|
-
|
84
|
-
##### Number
|
85
|
-
|
86
|
-
Number filters can be used on any `integer`, `float`, or `decimal` columns, or you can define your own number filter (see [Custom Filters](#custom-filters)).
|
87
|
-
|
88
|
-
```yaml
|
89
|
-
measure: flight
|
90
|
-
filters:
|
91
|
-
- key: delay
|
92
|
-
criteria:
|
93
|
-
operator: '>'
|
94
|
-
value: 15
|
95
|
-
dimensions:
|
96
|
-
- carrier
|
97
|
-
```
|
98
|
-
[<img src="images/flights_with_configured_number.png?raw=true" width="500" />](images/flights_with_configured_number.png?raw=true)
|
99
|
-
|
100
|
-
##### String
|
101
|
-
|
102
|
-
String filters can be used on any `string` or `text` columns, or you can define your own number filter (see [Custom Filters](#custom-filters)).
|
103
|
-
|
104
|
-
```yaml
|
105
|
-
measure: flight
|
106
|
-
filters:
|
107
|
-
- key: carrier_name
|
108
|
-
criteria:
|
109
|
-
operator: contains
|
110
|
-
value: airlines
|
111
|
-
dimensions:
|
112
|
-
- carrier
|
113
|
-
```
|
114
|
-
[<img src="images/flights_with_configured_string.png?raw=true" width="500" />](images/flights_with_configured_string.png?raw=true)
|
115
|
-
|
116
|
-
##### Custom Filters
|
117
|
-
|
118
|
-
You can define custom filters in your model. For example, if `Flight` has a column named `delay` (an integer with a unit of minutes), then we can define a `was_delayed` dimension:
|
119
|
-
|
120
|
-
```ruby
|
121
|
-
class Flight < ApplicationRecord
|
122
|
-
include ReportsKit::Model
|
123
|
-
|
124
|
-
reports_kit do
|
125
|
-
filter :was_delayed, :boolean, conditions: 'delay IS NOT NULL AND delay > 15'
|
126
|
-
end
|
127
|
-
end
|
128
|
-
```
|
129
|
-
|
130
|
-
We can then use the `was_delayed` filter:
|
131
|
-
|
132
|
-
```yaml
|
133
|
-
measure: flight
|
134
|
-
filters:
|
135
|
-
- key: was_delayed
|
136
|
-
criteria:
|
137
|
-
value: true
|
138
|
-
dimensions:
|
139
|
-
- carrier
|
140
|
-
```
|
141
|
-
[<img src="images/flights_by_hours_delayed.png?raw=true" width="500" />](images/flights_by_hours_delayed.png?raw=true)
|
142
|
-
|
143
|
-
#### Form Controls
|
144
|
-
|
145
|
-
Most charting libraries don't provide interactive form controls, but ReportsKit does. It makes it easy to add form controls to allow end users to modify charts.
|
146
|
-
|
147
|
-
##### Check Box
|
148
|
-
|
149
|
-
Check boxes can be used with filters that have a `boolean` type.
|
150
|
-
|
151
|
-
```yaml
|
152
|
-
measure: flight
|
153
|
-
filters:
|
154
|
-
- is_on_time
|
155
|
-
dimensions:
|
156
|
-
- flight_at
|
157
|
-
- carrier
|
158
|
-
```
|
159
|
-
```haml
|
160
|
-
= render_report 'filter_check_box' do |f|
|
161
|
-
.checkbox
|
162
|
-
= label_tag :is_on_time do
|
163
|
-
= f.check_box :is_on_time
|
164
|
-
On time
|
165
|
-
```
|
166
|
-
[<img src="images/flights_with_check_box.png?raw=true" width="500" />](images/flights_with_check_box.png?raw=true)
|
167
|
-
|
168
|
-
##### Date Range
|
169
|
-
|
170
|
-
Date ranges can be used with filters that have a `datetime` type.
|
171
|
-
|
172
|
-
```yaml
|
173
|
-
measure: flight
|
174
|
-
filters:
|
175
|
-
- flight_at
|
176
|
-
dimensions:
|
177
|
-
- flight_at
|
178
|
-
- carrier
|
179
|
-
```
|
180
|
-
```haml
|
181
|
-
= render_report 'filter_date_range' do |f|
|
182
|
-
= f.date_range :flight_at
|
183
|
-
```
|
184
|
-
[<img src="images/flights_with_date_range.png?raw=true" width="500" />](images/flights_with_date_range.png?raw=true)
|
185
|
-
|
186
|
-
##### Multi-Autocomplete
|
187
|
-
|
188
|
-
```yaml
|
189
|
-
measure: flight
|
190
|
-
filters:
|
191
|
-
- carrier
|
192
|
-
dimensions:
|
193
|
-
- flight_at
|
194
|
-
- carrier
|
195
|
-
```
|
196
|
-
```haml
|
197
|
-
= render_report 'filter_multi_autocomplete' do |f|
|
198
|
-
= f.multi_autocomplete :carrier, scope: 'top', placeholder: 'Carrier...'
|
199
|
-
```
|
200
|
-
[<img src="images/flights_with_multi_autocomplete.png?raw=true" width="500" />](images/flights_with_multi_autocomplete.png?raw=true)
|
201
|
-
|
202
|
-
##### String Filter
|
203
|
-
|
204
|
-
```yaml
|
205
|
-
measure: flight
|
206
|
-
filters:
|
207
|
-
- carrier_name
|
208
|
-
dimensions:
|
209
|
-
- flight_at
|
210
|
-
- carrier
|
211
|
-
```
|
212
|
-
```haml
|
213
|
-
= render_report 'filter_string' do |f|
|
214
|
-
= f.string_filter :carrier_name, placeholder: 'Carrier name (e.g. Airlines)...', style: 'width: 175px;'
|
215
|
-
```
|
216
|
-
[<img src="images/flights_with_string_filter.png?raw=true" width="500" />](images/flights_with_string_filter.png?raw=true)
|
Binary file
|
data/docs/images/dashed_line.png
DELETED
Binary file
|
data/docs/images/demo_area.png
DELETED
Binary file
|
Binary file
|
Binary file
|
data/docs/images/demo_legend.png
DELETED
Binary file
|
Binary file
|
data/docs/images/demo_radar.png
DELETED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/docs/measures.md
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
### Measures
|
2
|
-
|
3
|
-
The measure is what is being counted (or aggregated in another way). You can use any model as the measure.
|
4
|
-
|
5
|
-
For example, say we have a `Flight` model with a `flight_at` datetime column. We can chart the number of flights over time:
|
6
|
-
|
7
|
-
```yaml
|
8
|
-
measure: flight
|
9
|
-
dimensions:
|
10
|
-
- flight_at
|
11
|
-
```
|
12
|
-
[<img src="images/flights_by_flight_at.png?raw=true" width="500" />](images/flights_by_flight_at.png?raw=true)
|