Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
IR_Project_inverted_index
Project
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kel. 2 IR Project
IR_Project_inverted_index
Commits
5ccddf1c
Commit
5ccddf1c
authored
May 29, 2020
by
Ventina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
02155302
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
97 additions
and
0 deletions
+97
-0
HandlerAPI.py
IR Project /HandlerAPI-master/HandlerAPI.py
+97
-0
No files found.
IR Project /HandlerAPI-master/HandlerAPI.py
0 → 100644
View file @
5ccddf1c
#!/usr/bin/env python3
import
requests
import
json
import
pandas
as
pd
from
operator
import
add
def
parsed_api
(
url
):
response
=
requests
.
get
(
url
)
data
=
response
.
text
parsed
=
json
.
loads
(
data
)
return
parsed
def
count_state
(
api_data
):
# arr = [] #array
data
=
{}
#dictionary{key:value}
count
=
0
user_state
=
{}
for
i
in
range
(
len
(
api_data
)):
temp
=
api_data
[
i
][
'user'
][
'login'
]
#temp untuk menyimpan nama developer
count
+=
1
if
temp
not
in
data
:
#jika temp tidak ada dalam dictionary, dia belum jadi key
data
[
temp
]
=
set
()
#set temp sebagai key dalam dictionary
data
[
temp
]
.
add
(
count
)
#tambahkan value untuk key yang saat ini
for
user
,
value
in
data
.
items
():
#dictionary di looping sebanyak panjang dictionary
user_state
[
user
]
=
set
()
#set user sebagai key dalam dictionary user_state
user_state
[
user
]
=
len
(
value
)
#tambahkan value dalam key user_state sepanjang nilai value
return
user_state
def
count_state_commit
(
api_data
):
data
=
{}
#dictionary{key:value}
count
=
0
user_state
=
{}
for
i
in
range
(
len
(
api_data
)):
temp
=
api_data
[
i
][
'author'
][
'login'
]
#temp untuk menyimpan nama developer
count
+=
1
if
temp
not
in
data
:
#jika temp tidak ada dalam data dictionary, dia belum jadi key
data
[
temp
]
=
set
()
#set temp sebagai key dalam dictionary
data
[
temp
]
.
add
(
count
)
#tambahkan value untuk key yang saat ini
for
user
,
value
in
data
.
items
():
#dictionary di looping sebanyak panjang dictionary
user_state
[
user
]
=
set
()
#set user sebagai key dalam dictionary user_state
user_state
[
user
]
=
len
(
value
)
#tambahkan value dalam key user_state sepanjang nilai value
return
user_state
def
count_loc
(
api_commit
):
locArr
=
[]
for
i
in
range
(
len
(
api_commit
)):
a
=
api_commit
[
i
][
'weeks'
]
arrA
=
[]
for
j
in
range
(
len
(
api_commit
[
i
][
'weeks'
])):
tempDict
=
api_commit
[
i
][
'weeks'
][
j
]
arr
=
[]
for
key
,
value
in
tempDict
.
items
():
arr
.
append
(
value
)
arrA
.
append
(
arr
)
locArr
.
append
(
arrA
)
ArrAdd
=
[]
ArrDel
=
[]
for
i
in
range
(
len
(
locArr
)):
tempArr
=
[]
tempArr2
=
[]
for
j
in
range
(
len
(
locArr
[
i
])):
tempArr
.
append
(
locArr
[
i
][
j
][
1
])
tempArr2
.
append
(
locArr
[
i
][
j
][
2
])
#print(j)
ArrAdd
.
append
(
tempArr
)
ArrDel
.
append
(
tempArr2
)
result_list
=
[]
for
i
in
range
(
len
(
ArrAdd
)):
result_list
.
append
(
list
(
map
(
add
,
ArrAdd
[
i
],
ArrDel
[
i
])))
loc_tot
=
[
]
for
i
in
range
(
len
(
result_list
)):
loc_tot
.
append
(
sum
(
result_list
[
i
]))
LOC_dict
=
{}
for
i
in
range
(
len
(
loc_tot
)):
developer
=
api_commit
[
i
][
'author'
][
'login'
]
LOC_dict
[
developer
]
=
loc_tot
[
i
]
return
LOC_dict
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