FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
roadmap/lib/org_date_rangeable.rb at main · DMPRoadmap/roadmap · GitHub
DMPRoadmap
roadmap
Repository navigation
Code
Issues
300
(300)
Pull requests
49
(49)
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
roadmap
/
lib
/
org_date_rangeable.rb
Copy path
More file actions
More file actions
Latest commit
History
History
History
37 lines (31 loc) · 1.04 KB
Breadcrumbs
roadmap
/
lib
/
org_date_rangeable.rb
Copy path
File metadata and controls
37 lines (31 loc) · 1.04 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# frozen_string_literal: true
# Helpers for generating usage statistics
module
OrgDateRangeable
def
monthly_range
(
org
:
,
start_date
:
nil
,
end_date
:
Date
.
today
.
end_of_month
,
filtered
:
false
)
query_string
=
'org_id = :org_id and filtered = :filtered'
query_hash
=
{
org_id
:
org
.
id
,
filtered
:
filtered
}
unless
start_date
.
nil?
query_string
+=
' and date >= :start_date'
query_hash
[
:start_date
]
=
start_date
end
unless
end_date
.
nil?
query_string
+=
' and date <= :end_date'
query_hash
[
:end_date
]
=
end_date
end
where
(
query_string
,
query_hash
)
end
class
<<
self
def
split_months_from_creation
(
org
,
&
block
)
starts_at
=
org
.
created_at
ends_at
=
starts_at
.
end_of_month
enumerable
=
[
]
until
starts_at
.
future?
||
ends_at
.
future?
yield
(
starts_at
,
ends_at
)
if
block
enumerable
<<
{
start_date
:
starts_at
,
end_date
:
ends_at
}
starts_at
=
starts_at
.
next_month
.
beginning_of_month
ends_at
=
starts_at
.
end_of_month
end
enumerable
end
end
end
Back
|
FazBrowse Home
|
New Git URL