백승욱

Add features(show openDt and audiAcc)

...@@ -22,11 +22,26 @@ exports.ShowYesterdayRank = function(replyToken) { ...@@ -22,11 +22,26 @@ exports.ShowYesterdayRank = function(replyToken) {
22 if(!error && response.statusCode == 200) { 22 if(!error && response.statusCode == 200) {
23 console.log(body.boxOfficeResult); 23 console.log(body.boxOfficeResult);
24 24
25 - var movie_1st = body.boxOfficeResult.dailyBoxOfficeList[0].movieNm; 25 + var movieName = [];
26 - var movie_2nd = body.boxOfficeResult.dailyBoxOfficeList[1].movieNm; 26 + movieName[0] = body.boxOfficeResult.dailyBoxOfficeList[0].movieNm;
27 - var movie_3rd = body.boxOfficeResult.dailyBoxOfficeList[2].movieNm; 27 + movieName[1] = body.boxOfficeResult.dailyBoxOfficeList[1].movieNm;
28 - var movie_4th = body.boxOfficeResult.dailyBoxOfficeList[3].movieNm; 28 + movieName[2] = body.boxOfficeResult.dailyBoxOfficeList[2].movieNm;
29 - var movie_5th = body.boxOfficeResult.dailyBoxOfficeList[4].movieNm; 29 + movieName[3] = body.boxOfficeResult.dailyBoxOfficeList[3].movieNm;
30 + movieName[4] = body.boxOfficeResult.dailyBoxOfficeList[4].movieNm;
31 +
32 + var movieOpenDt = [];
33 + movieOpenDt[0] = body.boxOfficeResult.dailyBoxOfficeList[0].openDt;
34 + movieOpenDt[1] = body.boxOfficeResult.dailyBoxOfficeList[1].openDt;
35 + movieOpenDt[2] = body.boxOfficeResult.dailyBoxOfficeList[2].openDt;
36 + movieOpenDt[3] = body.boxOfficeResult.dailyBoxOfficeList[3].openDt;
37 + movieOpenDt[4] = body.boxOfficeResult.dailyBoxOfficeList[4].openDt;
38 +
39 + var movieAudiAcc = [];
40 + movieAudiAcc[0] = exports.numberWithCommas(body.boxOfficeResult.dailyBoxOfficeList[0].audiAcc);
41 + movieAudiAcc[1] = exports.numberWithCommas(body.boxOfficeResult.dailyBoxOfficeList[1].audiAcc);
42 + movieAudiAcc[2] = exports.numberWithCommas(body.boxOfficeResult.dailyBoxOfficeList[2].audiAcc);
43 + movieAudiAcc[3] = exports.numberWithCommas(body.boxOfficeResult.dailyBoxOfficeList[3].audiAcc);
44 + movieAudiAcc[4] = exports.numberWithCommas(body.boxOfficeResult.dailyBoxOfficeList[4].audiAcc);
30 45
31 request.post( 46 request.post(
32 { 47 {
...@@ -40,11 +55,11 @@ exports.ShowYesterdayRank = function(replyToken) { ...@@ -40,11 +55,11 @@ exports.ShowYesterdayRank = function(replyToken) {
40 { 55 {
41 "type":"text", 56 "type":"text",
42 "text": 57 "text":
43 - `1위 : ${movie_1st}\n`+ 58 + `[1위]\n영화제목 : ${movieName[0]}\n개봉일 : ${movieOpenDt[0]}\n누적 관객 수 : ${movieAudiAcc[0]}명\n\n`+
44 - `2위 : ${movie_2nd}\n`+ 59 + `[2위]\n영화제목 : ${movieName[1]}\n개봉일 : ${movieOpenDt[1]}\n누적 관객 수 : ${movieAudiAcc[1]}명\n\n`+
45 - `3위 : ${movie_3rd}\n`+ 60 + `[3위]\n영화제목 : ${movieName[2]}\n개봉일 : ${movieOpenDt[2]}\n누적 관객 수 : ${movieAudiAcc[2]}명\n\n`+
46 - `4위 : ${movie_4th}\n`+ 61 + `[4위]\n영화제목 : ${movieName[3]}\n개봉일 : ${movieOpenDt[3]}\n누적 관객 수 : ${movieAudiAcc[3]}명\n\n`+
47 - `5위 : ${movie_5th}\n` 62 + `[5위]\n영화제목 : ${movieName[4]}\n개봉일 : ${movieOpenDt[4]}\n누적 관객 수 : ${movieAudiAcc[4]}명\n\n`
48 } 63 }
49 ] 64 ]
50 } 65 }
...@@ -67,4 +82,10 @@ exports.GetYesterday = function() { ...@@ -67,4 +82,10 @@ exports.GetYesterday = function() {
67 var day = ('0' + yesterday.getDate()).slice(-2); 82 var day = ('0' + yesterday.getDate()).slice(-2);
68 83
69 return (year + month + day); 84 return (year + month + day);
70 -}
...\ No newline at end of file ...\ No newline at end of file
85 +}
86 +
87 +
88 +// 숫자 사이에 콤마(,) 찍고 반환하는 함수(입력, 출력 모두 문자열)
89 +exports.numberWithCommas = function(x) {
90 + return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
91 +}
......