dm_filter 0.0.3 → 0.0.4
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 +5 -5
- data/.gitignore +2 -0
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +160 -0
- data/.travis.yml +23 -0
- data/Gemfile +7 -0
- data/README.md +21 -9
- data/Rakefile +2 -2
- data/bin/console +3 -3
- data/dm_filter.gemspec +17 -20
- data/lib/dm_filter.rb +33 -3
- data/lib/dm_filter/version.rb +1 -1
- metadata +69 -5
- data/lib/dm_filter/base.rb +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 835931d9c805e2313b152a9df5e819a10c876138af37842b16d34d83b1eb8c69
|
4
|
+
data.tar.gz: 96399fa5fdb892334422e6a300a976382964db3308ec1ac9b2324e63c7e36005
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd4604588da1f6e3dd0584ed5dd95af95273c272e30726ff6b81257432bbe229d016f29dc0facb3ea2a0ae82889654535978738dba8594bf77e3b3882859ec54
|
7
|
+
data.tar.gz: e7fa5b7934270fb4d9f6eccc1d8ff6c97fdc13a5e1d0513419995253852019af580d3de8387b66745cfc689f7159f6bf66907d150e365a19adff455fd684d783
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2018-07-22 17:04:38 +0800 using RuboCop version 0.58.1.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 2
|
10
|
+
# Cop supports --auto-correct.
|
11
|
+
# Configuration parameters: Include, TreatCommentsAsGroupSeparators.
|
12
|
+
# Include: **/*.gemfile, **/Gemfile, **/gems.rb
|
13
|
+
Bundler/OrderedGems:
|
14
|
+
Exclude:
|
15
|
+
# - 'Gemfile'
|
16
|
+
|
17
|
+
# Offense count: 1
|
18
|
+
# Cop supports --auto-correct.
|
19
|
+
Layout/EmptyLineAfterMagicComment:
|
20
|
+
Exclude:
|
21
|
+
# - 'dm_filter.gemspec'
|
22
|
+
|
23
|
+
# Offense count: 1
|
24
|
+
# Cop supports --auto-correct.
|
25
|
+
# Configuration parameters: EnforcedStyle.
|
26
|
+
# SupportedStyles: empty_lines, no_empty_lines
|
27
|
+
Layout/EmptyLinesAroundBlockBody:
|
28
|
+
Exclude:
|
29
|
+
# - 'spec/dm_filter_spec.rb'
|
30
|
+
|
31
|
+
# Offense count: 22
|
32
|
+
# Cop supports --auto-correct.
|
33
|
+
# Configuration parameters: Width, IgnoredPatterns.
|
34
|
+
Layout/IndentationWidth:
|
35
|
+
Exclude:
|
36
|
+
# - 'lib/dm_filter.rb'
|
37
|
+
# - 'spec/dm_filter_spec.rb'
|
38
|
+
|
39
|
+
# Offense count: 27
|
40
|
+
# Cop supports --auto-correct.
|
41
|
+
# Configuration parameters: IndentationWidth.
|
42
|
+
Layout/Tab:
|
43
|
+
Exclude:
|
44
|
+
# - 'lib/dm_filter.rb'
|
45
|
+
|
46
|
+
# Offense count: 2
|
47
|
+
# Cop supports --auto-correct.
|
48
|
+
# Configuration parameters: EnforcedStyle.
|
49
|
+
# SupportedStyles: final_newline, final_blank_line
|
50
|
+
Layout/TrailingBlankLines:
|
51
|
+
Exclude:
|
52
|
+
# - 'Gemfile'
|
53
|
+
# - 'spec/dm_filter_spec.rb'
|
54
|
+
|
55
|
+
# Offense count: 2
|
56
|
+
# Cop supports --auto-correct.
|
57
|
+
# Configuration parameters: AllowInHeredoc.
|
58
|
+
Layout/TrailingWhitespace:
|
59
|
+
Exclude:
|
60
|
+
# - 'lib/dm_filter.rb'
|
61
|
+
# - 'spec/dm_filter_spec.rb'
|
62
|
+
|
63
|
+
# Offense count: 1
|
64
|
+
Metrics/AbcSize:
|
65
|
+
Max: 45
|
66
|
+
|
67
|
+
# Offense count: 1
|
68
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
69
|
+
# ExcludedMethods: refine
|
70
|
+
Metrics/BlockLength:
|
71
|
+
Max: 29
|
72
|
+
|
73
|
+
# Offense count: 1
|
74
|
+
Metrics/CyclomaticComplexity:
|
75
|
+
Max: 11
|
76
|
+
|
77
|
+
# Offense count: 1
|
78
|
+
# Configuration parameters: CountComments.
|
79
|
+
Metrics/MethodLength:
|
80
|
+
Max: 21
|
81
|
+
|
82
|
+
# Offense count: 2
|
83
|
+
Style/Documentation:
|
84
|
+
Exclude:
|
85
|
+
# - 'spec/**/*'
|
86
|
+
# - 'test/**/*'
|
87
|
+
# - 'lib/dm_filter.rb'
|
88
|
+
|
89
|
+
# Offense count: 1
|
90
|
+
# Cop supports --auto-correct.
|
91
|
+
Style/Encoding:
|
92
|
+
Exclude:
|
93
|
+
# - 'dm_filter.gemspec'
|
94
|
+
|
95
|
+
# Offense count: 1
|
96
|
+
# Cop supports --auto-correct.
|
97
|
+
Style/ExpandPathArguments:
|
98
|
+
Exclude:
|
99
|
+
# - 'dm_filter.gemspec'
|
100
|
+
|
101
|
+
# Offense count: 1
|
102
|
+
# Cop supports --auto-correct.
|
103
|
+
# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
|
104
|
+
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
|
105
|
+
Style/HashSyntax:
|
106
|
+
Exclude:
|
107
|
+
# - 'Rakefile'
|
108
|
+
|
109
|
+
# Offense count: 1
|
110
|
+
Style/MixinUsage:
|
111
|
+
Exclude:
|
112
|
+
- 'spec/db/helper.rb'
|
113
|
+
|
114
|
+
# Offense count: 1
|
115
|
+
# Cop supports --auto-correct.
|
116
|
+
Style/MutableConstant:
|
117
|
+
Exclude:
|
118
|
+
# - 'lib/dm_filter/version.rb'
|
119
|
+
|
120
|
+
# Offense count: 2
|
121
|
+
# Cop supports --auto-correct.
|
122
|
+
# Configuration parameters: PreferredDelimiters.
|
123
|
+
Style/PercentLiteralDelimiters:
|
124
|
+
Exclude:
|
125
|
+
# - 'dm_filter.gemspec'
|
126
|
+
|
127
|
+
# Offense count: 8
|
128
|
+
# Cop supports --auto-correct.
|
129
|
+
Style/RedundantSelf:
|
130
|
+
Exclude:
|
131
|
+
# - 'lib/dm_filter.rb'
|
132
|
+
|
133
|
+
# Offense count: 1
|
134
|
+
# Cop supports --auto-correct.
|
135
|
+
Style/RescueModifier:
|
136
|
+
Exclude:
|
137
|
+
- 'spec/db/helper.rb'
|
138
|
+
|
139
|
+
# Offense count: 12
|
140
|
+
# Cop supports --auto-correct.
|
141
|
+
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
|
142
|
+
# SupportedStyles: single_quotes, double_quotes
|
143
|
+
Style/StringLiterals:
|
144
|
+
Exclude:
|
145
|
+
# - 'Rakefile'
|
146
|
+
# - 'bin/console'
|
147
|
+
# - 'dm_filter.gemspec'
|
148
|
+
# - 'lib/dm_filter/version.rb'
|
149
|
+
|
150
|
+
# Offense count: 2
|
151
|
+
# Cop supports --auto-correct.
|
152
|
+
Style/UnneededPercentQ:
|
153
|
+
Exclude:
|
154
|
+
# - 'dm_filter.gemspec'
|
155
|
+
|
156
|
+
# Offense count: 11
|
157
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
158
|
+
# URISchemes: http, https
|
159
|
+
Metrics/LineLength:
|
160
|
+
Max: 158
|
data/.travis.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.4.1
|
5
|
+
services: mysql
|
6
|
+
before_install: gem install bundler -v 1.16.1
|
7
|
+
notifications: false
|
8
|
+
|
9
|
+
env:
|
10
|
+
global:
|
11
|
+
- CC_TEST_REPORTER_ID=e3a1e96d871b3246e51eeeb6d9d3c901b93a445bd1ab710f30aadbdb4ba9ef0a
|
12
|
+
|
13
|
+
before_script:
|
14
|
+
- bundle exec rspec && CODECLIMATE_REPO_TOKEN=e3a1e96d871b3246e51eeeb6d9d3c901b93a445bd1ab710f30aadbdb4ba9ef0a
|
15
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
16
|
+
- chmod +x ./cc-test-reporter
|
17
|
+
- ./cc-test-reporter before-build
|
18
|
+
|
19
|
+
scripts:
|
20
|
+
- bundle exec rspec spec
|
21
|
+
|
22
|
+
after_script:
|
23
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
[](https://travis-ci.org/denmarkmeralpis/dm_filter) [](https://codeclimate.com/github/denmarkmeralpis/dm_filter/maintainability) [](https://codeclimate.com/github/denmarkmeralpis/dm_filter/test_coverage) [](https://badge.fury.io/rb/dm_filter)
|
1
2
|
# DmFilter
|
2
3
|
|
3
4
|
DmFilter is a very light weight Rails plugin that makes it easy to fetch your ActiveRecord lists using date or text as a parameter.
|
@@ -7,7 +8,7 @@ DmFilter is a very light weight Rails plugin that makes it easy to fetch your Ac
|
|
7
8
|
Add this line to your application's Gemfile:
|
8
9
|
|
9
10
|
```ruby
|
10
|
-
gem 'dm_filter'
|
11
|
+
gem 'dm_filter', '~> 0.0.3'
|
11
12
|
```
|
12
13
|
|
13
14
|
And then execute:
|
@@ -16,16 +17,21 @@ And then execute:
|
|
16
17
|
|
17
18
|
Or install it yourself as:
|
18
19
|
|
19
|
-
$ gem install dm_filter
|
20
|
+
$ gem install dm_filter -v 0.0.3
|
20
21
|
|
21
|
-
include this into your model
|
22
|
-
##### invoice.rb
|
22
|
+
include this into your model
|
23
23
|
```ruby
|
24
|
-
include DmFilter
|
24
|
+
include DmFilter
|
25
|
+
```
|
26
|
+
example
|
27
|
+
```ruby
|
28
|
+
class Invoice < ApplicationRecord
|
29
|
+
include DmFilter
|
30
|
+
end
|
25
31
|
```
|
26
32
|
|
27
33
|
## Usage
|
28
|
-
#### Values for `
|
34
|
+
#### Values for `duration`
|
29
35
|
1. `all` (default)
|
30
36
|
2. `today`
|
31
37
|
3. `yesterday`
|
@@ -35,14 +41,20 @@ include DmFilter::Base
|
|
35
41
|
7. `period`
|
36
42
|
|
37
43
|
#### Available options
|
38
|
-
1. `
|
44
|
+
1. `duration`(default is `all`)
|
39
45
|
2. `from`(if `day` is equal to `period`)
|
40
46
|
3. `to`(if `day` is equal to `period`)
|
41
|
-
4. `
|
47
|
+
4. `column_date` (default is `created_at`)
|
42
48
|
|
43
49
|
#### Example
|
44
50
|
```ruby
|
45
|
-
|
51
|
+
# specifying column_date
|
52
|
+
Invoice.dm_get(duration: 'today', column_date: 'paid_at')
|
53
|
+
```
|
54
|
+
or simply
|
55
|
+
```ruby
|
56
|
+
# default column_date is created_at
|
57
|
+
Invoice.dm_get(duration: 'today')
|
46
58
|
```
|
47
59
|
|
48
60
|
## Contributing
|
data/Rakefile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require
|
2
|
-
task :
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
task default: :spec
|
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'dm_filter'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +10,5 @@ require "dm_filter"
|
|
10
10
|
# require "pry"
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start
|
data/dm_filter.gemspec
CHANGED
@@ -1,32 +1,29 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'dm_filter/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
6
|
+
spec.name = 'dm_filter'
|
8
7
|
spec.version = DmFilter::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
8
|
+
spec.authors = ['Nujian Den Mark Meralpis']
|
9
|
+
spec.email = ['denmarkmeralpis@gmail.com']
|
11
10
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
11
|
+
spec.summary = 'Fetch ActiveRecord list using specified period as a parameter'
|
12
|
+
spec.description = 'DmFilter is a very light weight Rails plugin that makes it easy to fetch your ActiveRecord lists using date or text as a parameter.'
|
13
|
+
spec.homepage = 'https://github.com/denmarkmeralpis/dm_filter'
|
14
|
+
spec.license = 'MIT'
|
16
15
|
|
17
|
-
|
18
|
-
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
-
# if spec.respond_to?(:metadata)
|
20
|
-
# spec.metadata['allowed_push_host'] = "Set to 'http://mygemserver.com'"
|
21
|
-
# else
|
22
|
-
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
-
# end
|
16
|
+
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.' unless spec.respond_to?(:metadata)
|
24
17
|
|
25
18
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
-
spec.bindir =
|
19
|
+
spec.bindir = 'exe'
|
27
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
-
spec.require_paths = [
|
21
|
+
spec.require_paths = ['lib']
|
29
22
|
|
30
|
-
spec.
|
31
|
-
spec.add_development_dependency
|
23
|
+
spec.add_dependency 'activerecord', '>= 4.2'
|
24
|
+
spec.add_development_dependency 'activesupport', '~> 4.2'
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1.12'
|
26
|
+
spec.add_development_dependency 'mysql2', '>= 0.3.13', '< 0.4.0'
|
27
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
32
29
|
end
|
data/lib/dm_filter.rb
CHANGED
@@ -1,6 +1,36 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'active_support/all'
|
2
|
+
require 'dm_filter/version'
|
3
3
|
|
4
|
+
# DmFilter
|
4
5
|
module DmFilter
|
5
|
-
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
# Class Method
|
8
|
+
module ClassMethods
|
9
|
+
def dm_get(options)
|
10
|
+
options[:column_date] = 'created_at' unless options[:column_date].present?
|
11
|
+
|
12
|
+
from = options[:from].blank? ? Time.current : options[:from].to_datetime
|
13
|
+
to = options[:to].blank? ? Time.current : options[:to].to_datetime
|
14
|
+
|
15
|
+
case options[:duration]
|
16
|
+
when 'all'
|
17
|
+
all
|
18
|
+
when 'today'
|
19
|
+
where(options[:column_date] => from.beginning_of_day..to.end_of_day)
|
20
|
+
when 'yesterday'
|
21
|
+
where(options[:column_date] => from.yesterday.beginning_of_day..to.yesterday.end_of_day)
|
22
|
+
when 'this_week'
|
23
|
+
where(options[:column_date] => from.beginning_of_week..to.end_of_week)
|
24
|
+
when 'this_month'
|
25
|
+
where(options[:column_date] => from.beginning_of_month..to.end_of_month)
|
26
|
+
when 'last_month'
|
27
|
+
where(options[:column_date] => from.last_month.beginning_of_month..to.last_month.end_of_month)
|
28
|
+
when 'period', 'custom'
|
29
|
+
where(options[:column_date] => from.beginning_of_day..to.end_of_day)
|
30
|
+
else
|
31
|
+
all
|
32
|
+
end
|
33
|
+
end
|
34
|
+
extend ClassMethods
|
35
|
+
end
|
6
36
|
end
|
data/lib/dm_filter/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm_filter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nujian Den Mark Meralpis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-07-22 00:00:00.000000000 Z
|
12
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'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.2'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.2'
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: bundler
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -24,6 +52,26 @@ dependencies:
|
|
24
52
|
- - "~>"
|
25
53
|
- !ruby/object:Gem::Version
|
26
54
|
version: '1.12'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: mysql2
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.3.13
|
62
|
+
- - "<"
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 0.4.0
|
65
|
+
type: :development
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: 0.3.13
|
72
|
+
- - "<"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 0.4.0
|
27
75
|
- !ruby/object:Gem::Dependency
|
28
76
|
name: rake
|
29
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +86,20 @@ dependencies:
|
|
38
86
|
- - "~>"
|
39
87
|
- !ruby/object:Gem::Version
|
40
88
|
version: '10.0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: rspec
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '3.0'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '3.0'
|
41
103
|
description: DmFilter is a very light weight Rails plugin that makes it easy to fetch
|
42
104
|
your ActiveRecord lists using date or text as a parameter.
|
43
105
|
email:
|
@@ -47,6 +109,9 @@ extensions: []
|
|
47
109
|
extra_rdoc_files: []
|
48
110
|
files:
|
49
111
|
- ".gitignore"
|
112
|
+
- ".rubocop.yml"
|
113
|
+
- ".rubocop_todo.yml"
|
114
|
+
- ".travis.yml"
|
50
115
|
- CODE_OF_CONDUCT.md
|
51
116
|
- Gemfile
|
52
117
|
- LICENSE.txt
|
@@ -56,9 +121,8 @@ files:
|
|
56
121
|
- bin/setup
|
57
122
|
- dm_filter.gemspec
|
58
123
|
- lib/dm_filter.rb
|
59
|
-
- lib/dm_filter/base.rb
|
60
124
|
- lib/dm_filter/version.rb
|
61
|
-
homepage:
|
125
|
+
homepage: https://github.com/denmarkmeralpis/dm_filter
|
62
126
|
licenses:
|
63
127
|
- MIT
|
64
128
|
metadata: {}
|
@@ -78,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
142
|
version: '0'
|
79
143
|
requirements: []
|
80
144
|
rubyforge_project:
|
81
|
-
rubygems_version: 2.
|
145
|
+
rubygems_version: 2.7.6
|
82
146
|
signing_key:
|
83
147
|
specification_version: 4
|
84
148
|
summary: Fetch ActiveRecord list using specified period as a parameter
|
data/lib/dm_filter/base.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
module DmFilter
|
2
|
-
module Base
|
3
|
-
extend ActiveSupport::Concern
|
4
|
-
module ClassMethods
|
5
|
-
|
6
|
-
def dm_get(options)
|
7
|
-
d = options[:from]
|
8
|
-
t = options[:to]
|
9
|
-
column_date = options[:column_date]
|
10
|
-
day = options[:duration]
|
11
|
-
|
12
|
-
column_date = column_date.blank? ? 'created_at' : column_date
|
13
|
-
d = d.blank? ? Time.zone.now : d.to_date
|
14
|
-
t = t.blank? ? Time.zone.now : t.to_date
|
15
|
-
|
16
|
-
case day
|
17
|
-
when "all"
|
18
|
-
self.all
|
19
|
-
when "today"
|
20
|
-
self.where(column_date => d.beginning_of_day..t.end_of_day)
|
21
|
-
when "yesterday"
|
22
|
-
self.where(column_date => d.yesterday.beginning_of_day..t.yesterday.end_of_day)
|
23
|
-
when "this_week"
|
24
|
-
self.where(column_date => d.beginning_of_week..t.end_of_week)
|
25
|
-
when "this_month"
|
26
|
-
self.where(column_date => d.beginning_of_month..t.end_of_month)
|
27
|
-
when "last_month"
|
28
|
-
self.where(column_date => d.last_month.beginning_of_month..t.last_month.end_of_month)
|
29
|
-
when "period"
|
30
|
-
self.where(column_date => d.beginning_of_day..t.end_of_day)
|
31
|
-
else
|
32
|
-
self.all
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
extend ClassMethods
|
37
|
-
end
|
38
|
-
end
|