Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
ventura-ghr
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
0
Merge Requests
0
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
ventura-ghr
Commits
be85533e
Commit
be85533e
authored
Jan 19, 2017
by
Bui Minh Duc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix github not load all of the issues
parent
71b3eb9f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
28 deletions
+78
-28
app/controllers/users_controller.rb
+16
-1
app/views/users/index.html.erb
+20
-15
github.log
+0
-0
lib/github_loader.rb
+42
-12
No files found.
app/controllers/users_controller.rb
View file @
be85533e
class
UsersController
<
ApplicationController
require
'ostruct'
def
index
@date
=
OpenStruct
.
new
(
params
[
:date
])
if
params
[
:date
]
@users
=
User
.
where
(
team_ventura:
true
)
#.includes(own_issues: [:review_comments, :comments]).where(issues: {is_pull: true, comments: { comment_type: 1 }}, )
@score
=
Hash
.
new
@users
.
each
do
|
user
|
...
...
@@ -8,7 +11,19 @@ class UsersController < ApplicationController
user_score
[
:before
]
=
{
0
=>
0
,
1
=>
0
,
2
=>
0
,
3
=>
0
}
user_score
[
:after
]
=
{
0
=>
0
,
1
=>
0
,
2
=>
0
,
3
=>
0
}
pulls
=
user
.
own_issues
.
includes
(
:review_comments
,
:comments
).
where
(
is_pull:
true
,
comments:
{
comment_type:
1
})
# byebug
pulls
=
user
.
own_issues
if
!
@date
.
nil?
if
!
@date
.
from
.
blank?
&&
!
@date
.
to
.
blank?
pulls
=
pulls
.
where
(
"issues.created_at > ? AND issues.created_at < ?"
,
Date
.
parse
(
@date
.
from
),
Date
.
parse
(
@date
.
to
))
elsif
!
@date
.
from
.
blank?
pulls
=
pulls
.
where
(
"issues.created_at > ?"
,
Date
.
parse
(
@date
.
from
))
elsif
!
@date
.
to
.
blank?
pulls
=
pulls
.
where
(
"issues.created_at < ?"
,
Date
.
parse
(
@date
.
to
))
end
end
pulls
=
pulls
.
includes
(
:review_comments
,
:comments
).
where
(
is_pull:
true
,
comments:
{
comment_type:
1
})
pulls
.
each
do
|
pull
|
rv_comments
=
pull
.
review_comments
rv_comments
.
each
do
|
rv_comment
|
...
...
app/views/users/index.html.erb
View file @
be85533e
<div
class=
"container"
>
<div
class=
"page-header"
>
<h3>
KPI for User
</h3>
<p>
KPI is calculated from comments on pull requests.
From and To fields are used to filter pull requests of user on this range of date.
</p>
</div>
<div
id=
"toolbar"
>
<
form
class=
"form-inline"
>
<
%=
form_for
:date
,
html:
{
class:
"form-inline"
},
method: :get
do
|
f
|
%
>
<div
class=
"form-group"
>
<
label
for=
"from"
>
From
</label
>
<
%=
f
.
label
:from
%
>
<div
class=
'input-group date'
id=
'from_date'
>
<
input
type=
'text'
class=
"form-control"
/
>
<span
class=
"input-group-addon"
>
<span
class=
"glyphicon glyphicon-calendar"
></span>
</span>
<
%=
f
.
text_field
:from
,
class:
"form-control"
%
>
<span
class=
"input-group-addon"
>
<span
class=
"glyphicon glyphicon-calendar"
></span>
</span>
</div>
<
label
for=
"to"
>
To
</label
>
<
%=
f
.
label
:to
%
>
<div
class=
'input-group date'
id=
'to_date'
>
<input
type=
'text'
class=
"form-control"
/>
<span
class=
"input-group-addon"
>
<span
class=
"glyphicon glyphicon-calendar"
></span>
</span>
</div>
<div
class=
"input-group"
>
<input
type=
"submit"
name=
"Filter"
class=
"btn btn-default"
>
<%=
f
.
text_field
:to
,
class:
"form-control"
%>
<span
class=
"input-group-addon"
>
<span
class=
"glyphicon glyphicon-calendar"
></span>
</span>
</div>
<%=
f
.
submit
"Submit"
,
class:
"btn btn-default"
%>
</div>
<
/form
>
<
%
end
%
>
</div>
<div>
...
...
github.log
View file @
be85533e
This source diff could not be displayed because it is too large. You can
view the blob
instead.
lib/github_loader.rb
View file @
be85533e
...
...
@@ -8,7 +8,8 @@ class GithubLoader
repos
=
client
.
org_repos
(
$org
)
last_page
=
1
unless
client
.
last_response
.
headers
[
:link
].
nil?
last_page
=
client
.
last_response
.
headers
[
:link
].
split
(
' '
)[
2
][
-
3
].
to_i
last_page
=
client
.
last_response
.
headers
[
:link
].
split
(
' '
)[
2
]
last_page
=
last_page
[
-
6
..-
1
][
/\d+/
].
to_i
end
for
i
in
(
1
..
last_page
)
...
...
@@ -39,7 +40,8 @@ class GithubLoader
labels
=
client
.
labels
(
$org
+
"/"
+
repo
.
name
)
last_page
=
1
unless
client
.
last_response
.
headers
[
:link
].
nil?
last_page
=
client
.
last_response
.
headers
[
:link
].
split
(
' '
)[
2
][
-
3
].
to_i
last_page
=
client
.
last_response
.
headers
[
:link
].
split
(
' '
)[
2
]
last_page
=
last_page
[
-
6
..-
1
][
/\d+/
].
to_i
end
for
i
in
(
1
..
last_page
)
...
...
@@ -76,7 +78,8 @@ class GithubLoader
users
=
client
.
org_members
(
$org
)
last_page
=
1
unless
client
.
last_response
.
headers
[
:link
].
nil?
last_page
=
client
.
last_response
.
headers
[
:link
].
split
(
' '
)[
2
][
-
3
].
to_i
last_page
=
client
.
last_response
.
headers
[
:link
].
split
(
' '
)[
2
]
last_page
=
last_page
[
-
6
..-
1
][
/\d+/
].
to_i
end
for
i
in
(
1
..
last_page
)
...
...
@@ -106,7 +109,8 @@ class GithubLoader
members
=
client
.
team_members
(
team
.
id
)
last_page
=
1
unless
client
.
last_response
.
headers
[
:link
].
nil?
last_page
=
client
.
last_response
.
headers
[
:link
].
split
(
' '
)[
2
][
-
3
].
to_i
last_page
=
client
.
last_response
.
headers
[
:link
].
split
(
' '
)[
2
]
last_page
=
last_page
[
-
6
..-
1
][
/\d+/
].
to_i
end
# byebug
for
i
in
(
1
..
last_page
)
...
...
@@ -125,12 +129,14 @@ class GithubLoader
$logger
.
info
"Insert issues"
list_db_user
=
User
.
all
list_db_label
=
Label
.
all
count
=
0
db_repos
.
each
do
|
repo
|
issues
=
client
.
list_issues
(
$org
+
"/"
+
repo
.
name
,
{
state:
"all"
})
last_page
=
1
unless
client
.
last_response
.
headers
[
:link
].
nil?
last_page
=
client
.
last_response
.
headers
[
:link
].
split
(
' '
)[
2
][
-
3
].
to_i
last_page
=
client
.
last_response
.
headers
[
:link
].
split
(
' '
)[
2
]
last_page
=
last_page
[
-
6
..-
1
][
/\d+/
].
to_i
end
for
i
in
(
1
..
last_page
)
...
...
@@ -219,10 +225,15 @@ class GithubLoader
end
end
end
db_issue
.
save
x
=
db_issue
.
save
# if x
count
+=
1
# end
end
end
end
$logger
.
info
"Count "
+
count
.
to_s
end
def
insert_comments
(
client
,
list_db_repo
)
...
...
@@ -232,7 +243,8 @@ class GithubLoader
comments
=
client
.
issues_comments
(
$org
+
"/"
+
db_repo
.
name
)
last_page
=
1
unless
client
.
last_response
.
headers
[
:link
].
nil?
last_page
=
client
.
last_response
.
headers
[
:link
].
split
(
' '
)[
2
][
-
3
].
to_i
last_page
=
client
.
last_response
.
headers
[
:link
].
split
(
' '
)[
2
]
last_page
=
last_page
[
-
6
..-
1
][
/\d+/
].
to_i
end
for
i
in
(
1
..
last_page
)
...
...
@@ -264,7 +276,8 @@ class GithubLoader
rv_comments
=
client
.
pull_requests_comments
(
$org
+
"/"
+
db_repo
.
name
)
last_page
=
1
unless
client
.
last_response
.
headers
[
:link
].
nil?
last_page
=
client
.
last_response
.
headers
[
:link
].
split
(
' '
)[
2
][
-
3
].
to_i
last_page
=
client
.
last_response
.
headers
[
:link
].
split
(
' '
)[
2
]
last_page
=
last_page
[
-
6
..-
1
][
/\d+/
].
to_i
end
for
i
in
(
1
..
last_page
)
...
...
@@ -309,13 +322,30 @@ class GithubLoader
pulls
=
issues
.
where
(
is_pull:
true
)
pulls
.
each
do
|
pull
|
if
pull
.
issue
.
nil?
content
=
pull
.
comments
.
first
content
=
""
if
pull
.
body
content
=
pull
.
body
+
" "
end
if
pull
.
comments
.
first
content
+=
pull
.
comments
.
first
.
body
end
unless
content
.
nil?
issue_number
=
/#[0-9]+/
.
match
(
content
.
body
)
unless
issue_number
.
nil?
issue_number
=
/#[0-9]+/
.
match
(
content
)
if
!
issue_number
.
nil?
issue
=
issues
.
where
(
repository_id:
pull
.
repository_id
).
find_by
(
number:
issue_number
.
to_s
[
1
..-
1
])
pull
.
issue
=
issue
# puts pull.save
puts
pull
.
save
else
# TODO fix logic bug here
lst_url
=
URI
.
extract
(
content
,
[
'http'
,
'https'
])
lst_url
.
each
do
|
url
|
if
url
.
include?
(
"github.com"
)
&&
url
.
include?
(
"issues"
)
# byebug
issue
=
issues
.
where
(
repository_id:
pull
.
repository_id
).
find_by
(
number:
url
.
split
(
"/"
).
last
)
pull
.
issue
=
issue
puts
pull
.
save
end
end
end
end
end
...
...
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