Skip to content

Commit 352e034

Browse files
committed
svn application별 분리 및 다중 조회기능 추가
1 parent c69a224 commit 352e034

File tree

2 files changed

+57
-37
lines changed

2 files changed

+57
-37
lines changed

zimmyrabbit/templates/jenkins/main.html

+16-10
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,24 @@
5858
'X-CSRFToken': csrftoken // CSRF 토큰 요청 헤더에 포함
5959
},
6060
success : function(data) {
61-
6261
let str = '';
63-
str += '<table>';
64-
65-
for(var i=0; i<data.account.length; i++) {
66-
str += " <tr>";
67-
str += " <td>" + data.account[i] + "</td>";
68-
str += " <td>" + data.commitLogs[i] + "</td>";
69-
str += " <td>" + data.dates[i] + "</td>";
70-
str += " </tr>"
62+
for(var i=0; i<data.length; i++) {
63+
str += "<h1>" + data[i].package + "</h1>"
64+
str += '<table>';
65+
str += '<tr>';
66+
str += '<th>Account</th>';
67+
str += '<th>Commit Logs</th>';
68+
str += '<th>Dates</th>';
69+
str += '</tr>';
70+
for(var j=0; j<data[i].context.account.length; j++) {
71+
str += " <tr>";
72+
str += " <td>" + data[i].context.account[j] + "</td>";
73+
str += " <td>" + data[i].context.commitLogs[j] + "</td>";
74+
str += " <td>" + data[i].context.dates[j] + "</td>";
75+
str += " </tr>"
76+
}
77+
str += '</table>'
7178
}
72-
str += '</table>'
7379
$(".svnlog").html(str);
7480
},
7581
error: function() {

zimmyrabbit/zimmyrabbit/views.py

+41-27
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from rest_framework.views import APIView
1212
from rest_framework.response import Response
1313
from django.http import Http404
14+
from datetime import datetime
1415

1516
from .serializers import BuildHistSerializer
1617
from .models import BuildHist
@@ -26,34 +27,47 @@ def check_model(request) :
2627
content = jsonObject.get('content')
2728
scontent = sorted(set(content.split()))
2829

29-
command = os.environ.get("SVN_ADDRESS") + content + '\"'
30-
print(command)
31-
output = subprocess.check_output(command, shell=True, text=True)
32-
33-
# 결과 파싱하여 계정, 날짜, 커밋로그 저장
34-
commits = []
35-
lines = output.split('------------------------------------------------------------------------')
36-
37-
accounts = []
38-
dates = []
39-
commit_logs = []
40-
41-
for i in range(1, len(lines)-1):
42-
line = lines[i].split(" | ")
43-
account = line[1].strip()
44-
date = line[2].strip()
45-
commit_log = line[-1].strip()
46-
accounts.append(account)
47-
dates.append(date)
48-
commit_logs.append(commit_log)
49-
50-
print("Accounts:", accounts)
51-
print("Dates:", dates)
52-
print("Commit Logs:", commit_logs)
53-
54-
context = {'account': accounts, 'dates': dates, 'commitLogs' : commit_logs}
30+
all_contexts = []
31+
32+
for i in range(0,len(scontent)):
33+
app = scontent[i][-2:]
34+
comp = scontent[i].split("_")[0]
35+
package = scontent[i].split("_")[1]
36+
contentUrl = ''
37+
if app == "xp" :
38+
contentUrl = f'xpapps/{comp}/{package}'
39+
else :
40+
contentUrl = f'components/{comp}/{package}'
41+
42+
command = os.environ.get("SVN_ADDRESS") + contentUrl + '\"'
43+
print(command)
44+
output = subprocess.check_output(command, shell=True, text=True)
45+
46+
# 결과 파싱하여 계정, 날짜, 커밋로그 저장
47+
commits = []
48+
lines = output.split('------------------------------------------------------------------------')
49+
50+
accounts = []
51+
dates = []
52+
commit_logs = []
53+
54+
for j in range(1, len(lines)-1):
55+
line = lines[j].split(" | ")
56+
account = line[1].strip()
57+
date = line[2].strip()
58+
commit_log = line[-1].strip()
59+
accounts.append(account)
60+
dates.append(date)
61+
commit_logs.append(commit_log)
62+
63+
print("Accounts:", accounts)
64+
print("Dates:", dates)
65+
print("Commit Logs:", commit_logs)
66+
67+
context = {'account': accounts, 'dates': dates, 'commitLogs' : commit_logs}
68+
all_contexts.append({'context' : context, 'package' : package})
5569

56-
return JsonResponse(context)
70+
return JsonResponse(all_contexts, safe=False)
5771

5872
def request_build(request):
5973
jsonObject = json.loads(request.body)

0 commit comments

Comments
 (0)