Skip to content
This repository was archived by the owner on Jul 31, 2025. It is now read-only.

Commit 6252edd

Browse files
committed
bug fix
1 parent bf603c8 commit 6252edd

8 files changed

Lines changed: 53 additions & 53 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package org.gitmining.bean;
22

33
public enum Sort {
4-
GENERAL,STAR,FORK,CONTRIBUTOR;
4+
GENERAL,STAR,FORK,CONTRIBUTOR,HOT;
55
}

src/main/java/org/gitmining/controller/OverviewController.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public Map getGeneralRepos(HttpServletRequest request,
7878
tagNameList.add(tag);
7979
tagNameList.add(language);
8080
tagNameList.add(year);
81-
81+
8282
int type = Integer.parseInt(request.getParameter("type"));
8383
List<Repository> repos = new ArrayList<Repository>();
8484
switch (type) {
@@ -115,14 +115,17 @@ public Map getTopTen(HttpServletRequest request,
115115
HttpServletResponse response) throws Exception {
116116
// TODO Auto-generated method stub
117117
Map<String, List> result = new HashMap<String, List>();
118-
String temp = request.getParameter("tag");
119-
String[] tagName = temp.substring(1, temp.length() - 1).split("ae");
118+
String tag = request.getParameter("tag");
119+
String language = request.getParameter("language");
120+
String year = request.getParameter("year");
121+
System.out.println(tag+","+language+","+year);
120122
List<String> tagNameList = new ArrayList<String>();
121-
for (int i = 0; i < tagName.length; i++) {
122-
tagNameList.add(tagName[i]);
123-
}
124-
List<SimpleRepo> repos = repoByTagDataService
125-
.getReposSortByHot(tagNameList);
123+
tagNameList.add(tag);
124+
tagNameList.add(language);
125+
tagNameList.add(year);
126+
127+
List<Repository> repos = repoByTagDataService
128+
.searchAndSortByTagPagination(tagNameList, Sort.HOT, 0, 5);
126129
result.put("repos", repos);
127130
return result;
128131
}

src/main/java/org/gitmining/dao/impl/RepositoryDaoImpl.java

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,11 @@ public List<Repository> getSimpleReposByTagNameAndSortPagination(
126126
// TODO Auto-generated method stub
127127

128128
Map<String, Object> map = new HashMap<String, Object>();
129-
if(!tag_name.get(0).equals("all"))
129+
if (!tag_name.get(0).equals("all"))
130130
map.put("tag", tag_name.get(0));
131-
if(!tag_name.get(1).equals("all"))
131+
if (!tag_name.get(1).equals("all"))
132132
map.put("language", tag_name.get(1));
133-
if(!tag_name.get(2).equals("all"))
133+
if (!tag_name.get(2).equals("all"))
134134
map.put("year", tag_name.get(2));
135135
map.put("beginItem", begin);
136136
map.put("itemsPerPage", itemsPerPage);
@@ -140,24 +140,27 @@ public List<Repository> getSimpleReposByTagNameAndSortPagination(
140140
"repo.getSimpleReposByTagNameSortGeneralPagination", map);
141141
} else if (type == Sort.STAR) {
142142
map.put("type", "stargazers");
143-
return sqlSession.selectList(
144-
"repo.getSimpleReposByTagNameSortPagination", map);
145143
} else if (type == Sort.FORK) {
146144
map.put("type", "fork_num");
147-
return sqlSession.selectList(
148-
"repo.getSimpleReposByTagNameSortPagination", map);
149-
} else {
145+
} else if (type == Sort.CONTRIBUTOR) {
150146
map.put("type", "contributor");
151-
return sqlSession.selectList(
152-
"repo.getSimpleReposByTagNameSortPagination", map);
147+
} else {
148+
map.put("type", "hot");
153149
}
150+
return sqlSession.selectList(
151+
"repo.getSimpleReposByTagNameSortPagination", map);
154152
}
155153

156154
@Override
157155
public int getResultCountPagination(List<String> tagName, Sort type) {
158156
// TODO Auto-generated method stub
159157
Map<String, Object> map = new HashMap<String, Object>();
160-
map.put("name", tagName);
158+
if (!tagName.get(0).equals("all"))
159+
map.put("tag", tagName.get(0));
160+
if (!tagName.get(1).equals("all"))
161+
map.put("language", tagName.get(1));
162+
if (!tagName.get(2).equals("all"))
163+
map.put("year", tagName.get(2));
161164
return sqlSession.selectList("repo.getSimpleReposByTagName", map)
162165
.size();
163166
}
@@ -173,7 +176,7 @@ public List<Integer> getStatCounts(String table) {
173176
// TODO Auto-generated method stub
174177
Map<String, Object> map = new HashMap<String, Object>();
175178
map.put("table", table);
176-
return sqlSession.selectList("repo.getStatCounts",map);
179+
return sqlSession.selectList("repo.getStatCounts", map);
177180
}
178181

179182
@Override
@@ -182,6 +185,6 @@ public List<String> getStatTypes(String table, String column) {
182185
Map<String, Object> map = new HashMap<String, Object>();
183186
map.put("table", table);
184187
map.put("column", column);
185-
return sqlSession.selectList("repo.getStatTypes",map);
188+
return sqlSession.selectList("repo.getStatTypes", map);
186189
}
187190
}

src/main/java/org/gitmining/mapper/repo.xml

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,19 @@
163163

164164
<select id="getSimpleReposByTagName" resultMap="simpleRepo">
165165
SELECT distinct
166-
re.id AS id
167-
,full_name,owner_name,description,update_time,language,stargazers,fork_num
168-
FROM repotest re,repo_tag rt, tag t where re.id = rt.`repo_id` and
169-
rt.`tag_id` = t.`id` and t.`name` in
170-
<foreach collection="name" item="item" index="index" open="("
171-
close=")" separator=",">
172-
#{item}
173-
</foreach>
166+
id,full_name,owner_name,description,update_time,language,stargazers,fork_num
167+
FROM repotest re where 1=1
168+
<if test="tag != null">
169+
AND re.id IN(select rt.repo_id from repo_tag rt,tag t where t.name = #{tag} and t.id = rt.tag_id)
170+
</if>
171+
172+
<if test="language != null">
173+
AND re.id IN(select repo_id from language where language = #{language})
174+
</if>
175+
176+
<if test="year != null">
177+
AND re.create_time LIKE concat(#{year},'%')
178+
</if>
174179
;
175180
</select>
176181

@@ -218,24 +223,6 @@
218223
order by ${type} desc limit #{beginItem}, #{itemsPerPage};
219224
</select>
220225

221-
<!-- top 10 -->
222-
<select id="getReposSortByHot" resultMap="simpleRepo"
223-
parameterType="map">
224-
select
225-
repotest.id,full_name,owner_name,description,update_time,language,stargazers,fork_num
226-
from repo_tag,repotest
227-
where repo_tag.repo_id = repotest.id and
228-
repo_tag.tag_id in
229-
<foreach collection="first" item="item" index="index" open="("
230-
close=")" separator=",">
231-
#{item}
232-
</foreach>
233-
group by repo_tag.repo_id
234-
having count(repo_tag.tag_id) = #{second}
235-
order by hot desc limit 5
236-
</select>
237-
238-
239226
<select id="getSimilarRepo" resultMap="repoPairRelation">
240227
select
241228
repo_id,relate_repo_id,similar from repo_similar where repo_id =

src/main/java/org/gitmining/service/impl/RepoByTagDataServiceImpl.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,11 @@ public List<SimpleRepo> getReposSortByHot(List<String> tags) {
9898
public List<Repository> searchAndSortByTagPagination(List<String> tagName,
9999
Sort type, int currentPage, int itemsPerPage) {
100100
// TODO Auto-generated method stub
101-
int begin = (currentPage - 1) * itemsPerPage;
102-
101+
int begin=0;
102+
if (currentPage!=0) {
103+
begin = (currentPage - 1) * itemsPerPage;
104+
}
105+
103106
List<Repository> simpleRepos = repositoryDao
104107
.getSimpleReposByTagNameAndSortPagination(tagName, type, begin,
105108
itemsPerPage);

src/main/webapp/static/js/allrepos.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ app.controller('generalCtrl', [
140140

141141
app.controller('topCtrl', function($scope, $http) {
142142
var url = '/GithubVisualization/TopTen', data = {
143-
tag : JSON.stringify(repotype),
143+
tag : repotype,
144+
language: language,
145+
year: createyear
144146
}, transFn = function(data) {
145147
return $.param(data);
146148
}, postCfg = {

src/main/webapp/static/js/repository.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,17 @@ $(document)
2121
// //popup : $('.custom.popup'),
2222
// position:'bottom left',
2323
// });
24+
25+
var id=$("#repoid").text();
2426

2527
var url = "/GithubVisualization/repository/score"
2628
$
2729
.ajax(
28-
2930
url,
3031
{
3132
type : 'GET',
3233
data : {
33-
"id" : 1
34+
"id" : id
3435
},
3536
success : function(data, textStatus) {
3637
$('#reposcorePic')

src/main/webapp/velocity/templates/repo.vm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
href="/GithubVisualization/static/css/repo.css">
33

44
#parse('/templates/searchrepo.vm')
5+
<p id="repoid" style="display:none;">$!result.repository.id</p>
56
<div id="repoinfo">
67
<!--客观信息-->
78
<h2 class="ui header">

0 commit comments

Comments
 (0)