Skip to content

Commit 10a5f38

Browse files
committed
增加Tab1的框架
1 parent c0541df commit 10a5f38

File tree

6 files changed

+124
-140
lines changed

6 files changed

+124
-140
lines changed

GitMiner-1.0-SNAPSHOT.jar

674 Bytes
Binary file not shown.

JavaSocketTest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def test1():
3333

3434
mdg = MainDataGenerator()
3535

36-
res = mdg.generateNew("https://github.com/MirageLyu/test.git")
36+
res = mdg.generateNew("https://github.com/NJU-Trust/DailyPlan")
3737

3838
print(res)
3939

app.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,17 @@ def show_repositories(repo_name):
270270
# 文件贡献图
271271
file_contributor_matrix = repoDB.get_FileContributorMatrix('FileContributorMatrix' + index)
272272
print('file_contributor_matrix', file_contributor_matrix)
273+
# 仓库基本信息
274+
repo_base_information = repoDB.get_repo_base_information(repo_name)
275+
print('repo_base_information', repo_base_information)
276+
273277
return render_template(
274278
"repositories_content.html",
275279
username=username,
276280
commit_times_list_by_day=commit_times_list_by_day,
277281
contributor_network_matrix=contributor_network_matrix,
278-
file_contributor_matrix=file_contributor_matrix
282+
file_contributor_matrix=file_contributor_matrix,
283+
repo_base_information = repo_base_information
279284
)
280285

281286

repoDB_Options.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,32 @@ def execute(self, sql_command):
3737
# 返回数据
3838
return datas
3939

40+
# TODO:展示仓库的基本信息
41+
def get_repo_base_information(self, repo_name):
42+
res = dict()
43+
res['commits'] = 0 # commits总数
44+
res['contributors'] = 0 # contributors数量
45+
res['start_time'] = '2010' # 建立时间
46+
res['top_ten_commits'] = []
47+
for i in range(10):
48+
res['top_ten_commits'].append({'name': 'x'+str(i), 'commits': 10-i})
49+
# 下面是弗雷歇距离参照 https://www.echartsjs.com/examples/en/editor.html?c=dataset-encode0&theme=light
50+
source = [
51+
['frechet', 'commits', 'contributor'],
52+
[89.3, 58212, 'Matcha Latte'],
53+
[57.1, 78254, 'Milk Tea'],
54+
[74.4, 41032, 'Cheese Cocoa'],
55+
[50.1, 12755, 'Cheese Brownie'],
56+
[89.7, 20145, 'Matcha Cocoa'],
57+
[68.1, 79146, 'Tea'],
58+
[19.6, 91852, 'Orange Juice'],
59+
[10.6, 101852, 'Lemon Juice'],
60+
[32.7, 20112, 'Walnut Brownie']
61+
]
62+
res['top_ten_frechet'] = source
63+
64+
return res
65+
4066
# 获得带有列名的数据库信息
4167
def get_col_and_datas(self, table_name):
4268
self.connect()
@@ -142,7 +168,7 @@ def get_ContributorNetworkMatrix(self, table_name):
142168
max = 10
143169
for i in range(1, infos.__len__()):
144170
for j in range(1, infos[0].__len__()):
145-
data.append([i-1, j-1, infos[i][j]])
171+
data.append([i - 1, j - 1, infos[i][j]])
146172
if infos[i][j] > max:
147173
max = infos[i][j]
148174

@@ -224,5 +250,6 @@ def print_format_datas(self, datas):
224250

225251
if __name__ == '__main__':
226252
repoDB = repoDB_Options()
227-
datas = repoDB.get_FileContributorMatrix("FileContributorMatrix5")
253+
# datas = repoDB.get_FileContributorMatrix("FileContributorMatrix5")
254+
datas = repoDB.get_repo_base_information("a")
228255
print(datas)
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{% macro repoBaseInformation(repo_base_information) %}
2+
<div style="margin: 15px">
3+
<h5>1.基本信息</h5>
4+
<table class="table">
5+
<thead>
6+
<th>commits总数</th>
7+
<th>contributors数量</th>
8+
<th>建立时间</th>
9+
</thead>
10+
<tbody>
11+
<tr>
12+
<td>{{ repo_base_information.commits }}</td>
13+
<td>{{ repo_base_information.contributors }}</td>
14+
<td>{{ repo_base_information.start_time }}</td>
15+
</tr>
16+
</tbody>
17+
</table>
18+
<h5>2.Top10 commits数量贡献者</h5>
19+
<table class="table">
20+
<thead>
21+
<th>contributor</th>
22+
<th>commits数量</th>
23+
</thead>
24+
<tbody>
25+
{% for item in repo_base_information.top_ten_commits %}
26+
<tr>
27+
<td>{{ item.name }}</td>
28+
<td>{{ item.commits }}</td>
29+
</tr>
30+
{% endfor %}
31+
</tbody>
32+
</table>
33+
<h5>3.Top10 总体-个人贡献(相对)相似度</h5>
34+
<div id="main2" style="width: 800px;height:500px;margin: 0 auto;"></div>
35+
</div>
36+
<script type="text/javascript">
37+
// 基于准备好的dom,初始化echarts实例
38+
var myChart2 = echarts.init(document.getElementById('main2'));
39+
// 指定图表的配置项和数据(注意要用tojson)
40+
var option2 = {
41+
dataset: {
42+
source: {{ repo_base_information.top_ten_frechet | tojson}}
43+
},
44+
grid: {containLabel: true},
45+
xAxis: {name: 'commits'},
46+
yAxis: {type: 'category'},
47+
visualMap: {
48+
orient: 'horizontal',
49+
left: 'center',
50+
min: 10,
51+
max: 100,
52+
text: ['High Score', 'Low Score'],
53+
// Map the score column to color
54+
dimension: 0,
55+
inRange: {
56+
color: ['#D7DA8B', '#E15457']
57+
}
58+
},
59+
series: [
60+
{
61+
type: 'bar',
62+
encode: {
63+
// Map the "amount" column to X axis.
64+
x: 'commits',
65+
// Map the "product" column to Y axis
66+
y: 'contributor'
67+
}
68+
}
69+
]
70+
};
71+
72+
// 使用刚指定的配置项和数据显示图表。
73+
myChart2.setOption(option2);
74+
</script>
75+
{% endmacro %}
76+

templates/repositories_content.html

Lines changed: 12 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
{% from 'macros/macros_form.html' import form_field %}
33
{% from 'macros/macros_CommitTimesListByDay.html' import commitTimesListByDay %}
44
{% from 'macros/macros_ContributorNetworkMatrix.html' import contributorNetworkMatrix %}
5-
{% from 'macros/macros_FileContributorMatrix.html' import fileContributorMatrix%}
5+
{% from 'macros/macros_FileContributorMatrix.html' import fileContributorMatrix %}
6+
{% from 'macros/macros_RepoBaseInformation.html' import repoBaseInformation%}
67
{% block scripts %}
78
{{ super() }}
89
<script src="{{ url_for('static', filename='js/echarts.js') }}"></script>
@@ -19,25 +20,25 @@
1920
<a class="nav-link active" id="search-tab" data-toggle="tab" href="#search" role="tab"
2021
aria-controls="search"
2122
aria-selected="false">
22-
<h6>贡献网络矩阵</h6>
23+
<h6>仓库基本信息</h6>
2324
</a>
2425
</li>
2526
<li class="nav-item">
2627
<a class="nav-link" id="home-tab" data-toggle="tab" href="#admin" role="tab" aria-controls="home"
2728
aria-selected="true">
28-
<h6>Commit时间分布图</h6>
29+
<h6>贡献演化</h6>
2930
</a>
3031
</li>
3132
<li class="nav-item">
3233
<a class="nav-link" id="profile-tab" data-toggle="tab" href="#edit" role="tab" aria-controls="profile"
3334
aria-selected="false">
34-
<h6>折线图</h6>
35+
<h6>空间分布</h6>
3536
</a>
3637
</li>
3738
<li class="nav-item">
3839
<a class="nav-link" id="contact-tab" data-toggle="tab" href="#audit" role="tab" aria-controls="contact"
3940
aria-selected="false">
40-
<h6>文件贡献矩阵</h6>
41+
<h6>协作关系</h6>
4142
</a>
4243
</li>
4344
<li class="nav-item">
@@ -48,157 +49,33 @@ <h6>多重柱状图</h6>
4849
</li>
4950
</ul>
5051
<div class="tab-content border border-top-0" id="myTabContent">
52+
<div class="tab-pane fade show active" id="search" role="tabpanel" aria-labelledby="search-tab">
53+
{{ repoBaseInformation(repo_base_information) }}
54+
</div>
5155
<div class="tab-pane fade" id="admin" role="tabpanel" aria-labelledby="home-tab">
5256
<!-- 为ECharts准备一个具备大小(宽高)的Dom -->
5357
{{ commitTimesListByDay(commit_times_list_by_day) }}
5458
</div>
5559
<div class="tab-pane fade" id="edit" role="tabpanel" aria-labelledby="profile-tab">
56-
<div id="main2" style="width: 800px;height:500px;margin: 0 auto;"></div>
60+
{{ fileContributorMatrix(file_contributor_matrix) }}
5761
</div>
5862
<div class="tab-pane fade" id="audit" role="tabpanel" aria-labelledby="contact-tab">
59-
{{ fileContributorMatrix(file_contributor_matrix) }}
63+
{{ contributorNetworkMatrix(contributor_network_matrix) }}
6064
</div>
6165
<div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">
6266
<div id="main4" style="width: 800px;height:500px;margin: 0 auto;"></div>
6367
</div>
64-
<div class="tab-pane fade show active" id="search" role="tabpanel" aria-labelledby="search-tab">
65-
{{ contributorNetworkMatrix(contributor_network_matrix) }}
66-
</div>
6768
</div>
6869

6970

7071

7172
<script type="text/javascript">
7273

7374
// 基于准备好的dom,初始化echarts实例
74-
var myChart2 = echarts.init(document.getElementById('main2'));
7575
var myChart4 = echarts.init(document.getElementById('main4'));
7676

7777
// 指定图表的配置项和数据
78-
var option2 = {
79-
title: {
80-
text: '未来一周气温变化',
81-
subtext: '纯属虚构'
82-
},
83-
tooltip: {
84-
trigger: 'axis'
85-
},
86-
legend: {
87-
data: ['最高气温', '最低气温']
88-
},
89-
toolbox: {
90-
show: true,
91-
feature: {
92-
mark: {show: true},
93-
dataView: {show: true, readOnly: false},
94-
magicType: {show: true, type: ['line', 'bar']},
95-
restore: {show: true},
96-
saveAsImage: {show: true}
97-
}
98-
},
99-
calculable: true,
100-
xAxis: [
101-
{
102-
type: 'category',
103-
boundaryGap: false,
104-
data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
105-
}
106-
],
107-
yAxis: [
108-
{
109-
type: 'value',
110-
axisLabel: {
111-
formatter: '{value} °C'
112-
}
113-
}
114-
],
115-
series: [
116-
{
117-
name: '最高气温',
118-
type: 'line',
119-
data: [11, 11, 15, 13, 12, 13, 10],
120-
markPoint: {
121-
data: [
122-
{type: 'max', name: '最大值'},
123-
{type: 'min', name: '最小值'}
124-
]
125-
},
126-
markLine: {
127-
data: [
128-
{type: 'average', name: '平均值'}
129-
]
130-
}
131-
},
132-
{
133-
name: '最低气温',
134-
type: 'line',
135-
data: [1, -2, 2, 5, 3, 2, 0],
136-
markPoint: {
137-
data: [
138-
{name: '周最低', value: -2, xAxis: 1, yAxis: -1.5}
139-
]
140-
},
141-
markLine: {
142-
data: [
143-
{type: 'average', name: '平均值'}
144-
]
145-
}
146-
}
147-
]
148-
};
149-
var option3 = {
150-
title: {
151-
text: '某站点用户访问来源',
152-
subtext: '纯属虚构',
153-
x: 'center'
154-
},
155-
tooltip: {
156-
trigger: 'item',
157-
formatter: "{a} <br/>{b} : {c} ({d}%)"
158-
},
159-
legend: {
160-
orient: 'vertical',
161-
x: 'left',
162-
data: ['直接访问', '邮件营销', '联盟广告', '视频广告', '搜索引擎']
163-
},
164-
toolbox: {
165-
show: true,
166-
feature: {
167-
mark: {show: true},
168-
dataView: {show: true, readOnly: false},
169-
magicType: {
170-
show: true,
171-
type: ['pie', 'funnel'],
172-
option: {
173-
funnel: {
174-
x: '25%',
175-
width: '50%',
176-
funnelAlign: 'left',
177-
max: 1548
178-
}
179-
}
180-
},
181-
restore: {show: true},
182-
saveAsImage: {show: true}
183-
}
184-
},
185-
calculable: true,
186-
series: [
187-
{
188-
name: '访问来源',
189-
type: 'pie',
190-
radius: '55%',
191-
center: ['50%', '60%'],
192-
data: [
193-
{value: 335, name: '直接访问'},
194-
{value: 310, name: '邮件营销'},
195-
{value: 234, name: '联盟广告'},
196-
{value: 135, name: '视频广告'},
197-
{value: 1548, name: '搜索引擎'}
198-
]
199-
}
200-
]
201-
};
78+
20279
var option4 = {
20380
tooltip: {
20481
trigger: 'axis',
@@ -272,7 +149,6 @@ <h6>多重柱状图</h6>
272149

273150

274151
// 使用刚指定的配置项和数据显示图表。
275-
myChart2.setOption(option2);
276152
myChart4.setOption(option4);
277153
</script>
278154
{% endblock %}

0 commit comments

Comments
 (0)