... | @@ -37,6 +37,9 @@ period_for :period, threshold: 15.minutes |
... | @@ -37,6 +37,9 @@ period_for :period, threshold: 15.minutes |
|
# This will force the creation of all the methods, which would raise an exception on conflicting. The default is false
|
|
# This will force the creation of all the methods, which would raise an exception on conflicting. The default is false
|
|
period_for :period, force: true
|
|
period_for :period, force: true
|
|
|
|
|
|
|
|
# If you don't want the methods to have the field name, then you can use this option
|
|
|
|
period_for: :period, prefixed: false
|
|
|
|
|
|
# You can also rename any method that will be created
|
|
# You can also rename any method that will be created
|
|
period_for :period, methods: { current: :ongoing, current?: :ongoing? }
|
|
period_for :period, methods: { current: :ongoing, current?: :ongoing? }
|
|
```
|
|
```
|
... | @@ -167,8 +170,6 @@ Filter records that the right value with the threshold is less than the one prov |
... | @@ -167,8 +170,6 @@ Filter records that the right value with the threshold is less than the one prov |
|
Checks if the value contains in the range as date. You can pass either an Arel attribute or a plain value.
|
|
Checks if the value contains in the range as date. You can pass either an Arel attribute or a plain value.
|
|
```
|
|
```
|
|
daterange(LOWER("events"."period")::date),UPPER("events"."period")::date) @> value
|
|
daterange(LOWER("events"."period")::date),UPPER("events"."period")::date) @> value
|
|
- With threshold -
|
|
|
|
daterange((LOWER("events"."period") - "events"."interval")::date),(UPPER("events"."period") + "events"."interval")::date) @> value
|
|
|
|
```
|
|
```
|
|
|
|
|
|
#### `:not_containing_date` as `.period_not_containing_date(value)` **(NON DATERANGE ONLY)**
|
|
#### `:not_containing_date` as `.period_not_containing_date(value)` **(NON DATERANGE ONLY)**
|
... | @@ -185,10 +186,6 @@ Checks if two ranges overlap but comparing only dates. You can pass either anoth |
... | @@ -185,10 +186,6 @@ Checks if two ranges overlap but comparing only dates. You can pass either anoth |
|
daterange(LOWER("events"."period")::date),UPPER("events"."period")::date) && value
|
|
daterange(LOWER("events"."period")::date),UPPER("events"."period")::date) && value
|
|
- OR -
|
|
- OR -
|
|
daterange(LOWER("events"."period")::date),UPPER("events"."period")::date) && daterange(left, right)
|
|
daterange(LOWER("events"."period")::date),UPPER("events"."period")::date) && daterange(left, right)
|
|
- With threshold -
|
|
|
|
daterange((LOWER("events"."period") - "events"."interval")::date),(UPPER("events"."period") + "events"."interval")::date) && value
|
|
|
|
- OR -
|
|
|
|
daterange((LOWER("events"."period") - "events"."interval")::date),(UPPER("events"."period") + "events"."interval")::date) && daterange(left, right)
|
|
|
|
```
|
|
```
|
|
|
|
|
|
#### `:not_overlapping_date` as `.period_not_overlapping_date(left, right = nil)` **(NON DATERANGE ONLY)**
|
|
#### `:not_overlapping_date` as `.period_not_overlapping_date(left, right = nil)` **(NON DATERANGE ONLY)**
|
... | @@ -197,10 +194,20 @@ The opposite version of the `:overlapping_date` scope. |
... | @@ -197,10 +194,20 @@ The opposite version of the `:overlapping_date` scope. |
|
NOT daterange(LOWER("events"."period")::date),UPPER("events"."period")::date) && value
|
|
NOT daterange(LOWER("events"."period")::date),UPPER("events"."period")::date) && value
|
|
- OR -
|
|
- OR -
|
|
NOT daterange(LOWER("events"."period")::date),UPPER("events"."period")::date) && daterange(left, right)
|
|
NOT daterange(LOWER("events"."period")::date),UPPER("events"."period")::date) && daterange(left, right)
|
|
- With threshold -
|
|
```
|
|
NOT daterange((LOWER("events"."period") - "events"."interval")::date),(UPPER("events"."period") + "events"."interval")::date) && value
|
|
|
|
|
|
#### `:real_containing_date` as `.period_real_containing_date(value)` **(NON DATERANGE ONLY)**
|
|
|
|
Checks if the value contains in the range as date and considering the threshold. You can pass either an Arel attribute or a plain value.
|
|
|
|
```
|
|
|
|
daterange((LOWER("events"."period") - "events"."interval")::date),(UPPER("events"."period") + "events"."interval")::date) @> value
|
|
|
|
```
|
|
|
|
|
|
|
|
#### `:real_overlapping_date` as `.period_real_overlapping_date(left, right = nil)` **(NON DATERANGE ONLY)**
|
|
|
|
Checks if two ranges overlap but comparing only dates and considering the threshold. You can pass either another range column as an Arel attribute, a plain range on the left, or the 2 parts of a range.
|
|
|
|
```
|
|
|
|
daterange((LOWER("events"."period") - "events"."interval")::date),(UPPER("events"."period") + "events"."interval")::date) && value
|
|
- OR -
|
|
- OR -
|
|
NOT daterange((LOWER("events"."period") - "events"."interval")::date),(UPPER("events"."period") + "events"."interval")::date) && daterange(left, right)
|
|
daterange((LOWER("events"."period") - "events"."interval")::date),(UPPER("events"."period") + "events"."interval")::date) && daterange(left, right)
|
|
```
|
|
```
|
|
|
|
|
|
### Instance methods
|
|
### Instance methods
|
... | | ... | |