Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
redmine_v2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
VeNtura
redmine_v2
Commits
34333349
Commit
34333349
authored
Dec 01, 2023
by
Tấn Trần Thanh
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/daily-report' into feature/plugin-workflow-report
parents
b4f35d92
94fcc54e
Pipeline
#1590
failed with stages
in 0 seconds
Changes
10
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
103 additions
and
1 deletions
+103
-1
plugins/workflow_report/app/controllers/workflow_report_controller.rb
+26
-1
plugins/workflow_report/app/helpers/workflow_report_helper.rb
+10
-0
plugins/workflow_report/app/models/workflow_report_time_entries.rb
+12
-0
plugins/workflow_report/app/views/workflow_report/_daily_report.html.slim
+14
-0
plugins/workflow_report/app/views/workflow_report/_side_content.html.slim
+4
-0
plugins/workflow_report/app/views/workflow_report/build_report.js.erb
+3
-0
plugins/workflow_report/app/views/workflow_report/index.html.slim
+3
-0
plugins/workflow_report/app/views/workflow_report/index_daily_report.html.slim
+21
-0
plugins/workflow_report/assets/stylesheets/style.css
+8
-0
plugins/workflow_report/config/routes.rb
+2
-0
No files found.
plugins/workflow_report/app/controllers/workflow_report_controller.rb
View file @
34333349
class
WorkflowReportController
<
ApplicationController
include
WorkflowReport
before_action
:authorize_global
before_action
:require_xhr_request
,
only:
:export
before_action
:require_xhr_request
,
only:
%i[export show_daily_report]
def
index
@team_options
=
$workflow_report_config
[
'teams'
].
map
{
|
team
|
team
.
keys
()
}
end
def
index_daily_report
@team_options
=
Project
.
visible
.
sorted
.
active
end
def
show_daily_report
date
=
params
[
:date
].
split
(
'-'
)
project_id
=
Project
.
find_by
(
name:
params
[
:team
]).
id
project_ids
=
Project
.
visible
.
active
.
where
(
parent_id:
project_id
).
pluck
(
:id
).
push
(
project_id
)
users_by_role
=
Project
.
find
(
project_id
).
users_by_role
result
=
[]
users_by_role
.
each
do
|
role
,
users
|
users
.
each
do
|
u
|
result
<<
{
id:
u
.
id
,
fullname:
"
#{
u
.
firstname
}
#{
u
.
lastname
}
"
}
unless
role
.
name
.
in?
(
%w[Manager JP TeamLead]
)
end
end
report
=
{}
result
.
each
do
|
user
|
report
[
user
[
:fullname
]]
=
WorkflowReportTimeEntries
.
query_time_entry
(
user
[
:id
],
date
[
0
].
to_i
,
date
[
1
].
to_i
,
date
[
2
].
to_i
,
project_ids
)
end
respond_to
do
|
format
|
format
.
js
{
render
'build_report'
,
locals:
{
report:
report
,
display_hour:
params
[
:display_hour
]
}
}
end
end
def
export
team
=
params
[
:team
]
project_ids
=
$workflow_report_config
[
'teams'
].
select
{
|
hash
|
hash
.
key?
(
team
)
}[
0
][
team
]
...
...
plugins/workflow_report/app/helpers/workflow_report_helper.rb
0 → 100644
View file @
34333349
module
WorkflowReportHelper
def
build_report
(
entry
)
done_ratio
=
entry
.
issue
.
done_ratio
github_issue_id
=
entry
.
issue
.
subject
.
match
(
/.*(#\d+).*/
)[
1
]
rescue
"#
#{
entry
.
issue
.
id
}
"
text
=
"
#{
entry
.
project
.
name
}#{
github_issue_id
}
:
#{
entry
.
activity
.
name
}
-
#{
entry
.
comments
}
"
text
.
concat
(
" (
#{
done_ratio
}
%)"
)
if
done_ratio
>
0
text
end
end
plugins/workflow_report/app/models/workflow_report_time_entries.rb
0 → 100644
View file @
34333349
class
WorkflowReportTimeEntries
<
TimeEntry
JP_TIME_ZONE
=
9
scope
:query_time_entry
,
->
(
user_id
,
year
,
month
,
day
,
project_ids
)
{
where
(
"
#{
TimeEntry
.
table_name
}
.user_id = ? AND
#{
TimeEntry
.
table_name
}
.spent_on BETWEEN ? AND ?"
,
user_id
,
DateTime
.
new
(
year
,
month
,
day
).
beginning_of_day
-
JP_TIME_ZONE
.
hours
,
DateTime
.
new
(
year
,
month
,
day
).
end_of_day
-
JP_TIME_ZONE
.
hours
).
where
(
projects:
{
id:
project_ids
}).
joins
(
:activity
,
:project
).
references
(
:issue
=>
[
:tracker
,
:status
]).
includes
(
:issue
=>
[
:tracker
,
:status
,
:assigned_to
,
:priority
]).
order
(
"
#{
TimeEntry
.
table_name
}
.spent_on DESC,
#{
Project
.
table_name
}
.name ASC,
#{
Tracker
.
table_name
}
.position ASC,
#{
Issue
.
table_name
}
.id ASC"
)
}
end
plugins/workflow_report/app/views/workflow_report/_daily_report.html.slim
0 → 100644
View file @
34333349
-
display_hour
=
ActiveRecord
::
Type
::
Boolean
.
new
.
type_cast_from_user
(
display_hour
)
p
=
"Project:
#{
params
[
:team
]
}
"
p
=
"*Daily Report
#{
params
[
:date
]
}
*"
-
report
.
each_with_index
do
|
(
username
,
entries
),
index
|
-
total_time
=
entries
.
reduce
(
0
)
{
|
acc
,
entry
|
acc
+
entry
.
hours
}
.mt-10
class
=
(
"bg-danger"
if
total_time
<
8)
span
=
"
#{
(
index
+
1
).
to_s
}
.
#{
username
}
#{
'('
+
total_time
.
to_s
+
'h)'
if
display_hour
}
"
-
entries
.
each
do
|
entry
|
div
span
-
#{build_report(entry)}
-
if
display_hour
span
=
" (
#{
entry
.
hours
}
h)"
plugins/workflow_report/app/views/workflow_report/_side_content.html.slim
0 → 100644
View file @
34333349
h3
Report
ul
li
=
link_to
'Workflow Report'
,
workflow_report_path
li
=
link_to
'Daily Report'
,
workflow_report_daily_path
plugins/workflow_report/app/views/workflow_report/build_report.js.erb
0 → 100644
View file @
34333349
<%
display_hour
=
display_hour
||
false
%>
$("#daily_report").html("
<%=
escape_javascript
(
render
partial:
'daily_report'
,
locals:
{
report:
report
,
display_hour:
display_hour
}
)
%>
")
plugins/workflow_report/app/views/workflow_report/index.html.slim
View file @
34333349
=
stylesheet_link_tag
'style'
,
plugin:
'workflow_report'
=
javascript_include_tag
(
:application
,
:plugin
=>
'workflow_report'
)
=
content_for
:sidebar
do
=
render
'side_content'
fieldset
.box.tabular
legend
|
EXPORT WORKFLOW
...
...
plugins/workflow_report/app/views/workflow_report/index_daily_report.html.slim
0 → 100644
View file @
34333349
=
stylesheet_link_tag
'style'
,
plugin:
'workflow_report'
=
javascript_include_tag
(
:application
,
:plugin
=>
'workflow_report'
)
=
content_for
:sidebar
do
=
render
'side_content'
fieldset
.box.tabular
legend
|
DAILY REPORT
=
form_tag
workflow_report_daily_export_path
,
method: :get
,
remote:
true
,
id:
'export-form'
do
p
=
label
:team
,
'Team'
=
select_tag
:team
,
options_for_select
(
@team_options
),
{
prompt:
"Select team"
}
p
=
label
:team
,
'Date'
=
date_field_tag
:date
,
Date
.
current
p
=
label
:display_hour
,
'Display hour'
=
check_box_tag
:display_hour
,
'1'
,
true
=
submit_tag
'export'
,
id:
'export'
#daily_report
plugins/workflow_report/assets/stylesheets/style.css
View file @
34333349
...
...
@@ -3,6 +3,10 @@
height
:
100vh
;
}
#daily_report
{
min-height
:
80vh
;
}
table
{
display
:
inline-block
;
table-layout
:
fixed
;
...
...
@@ -26,6 +30,10 @@ table {
z-index
:
1
;
}
.mt-10
{
margin-top
:
10px
;
}
.green
{
background-color
:
#92ce92
;
}
...
...
plugins/workflow_report/config/routes.rb
View file @
34333349
...
...
@@ -3,3 +3,5 @@
get
'workflow_report'
,
to:
'workflow_report#index'
get
'workflow_report/export'
,
to:
'workflow_report#export'
get
'workflow_report/daily'
,
to:
'workflow_report#index_daily_report'
get
'workflow_report/daily/export'
,
to:
'workflow_report#show_daily_report'
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment