@@ -110,21 +110,17 @@ async function enrichDataWithMySQL(results, currentUserId = null) {
110110 // D-Day UI ๊ณ์ฐ
111111 let dDay = "์์" ;
112112 let isTodayEnd = false ;
113+
113114 if ( post . end_date ) {
114115 const now = new Date ( ) ;
115116 const endDate = new Date ( post . end_date ) ;
116- const isPast = endDate < now ;
117117
118- if ( isPast ) {
119- // UI์์๋ ์๊ฐ ์ค์ ์ ๋ ๊ธ์ด 00:00์ด๋ผ์ ๋ง๊ฐ๋๋ค๊ณ ํ์๋๋ ๊ฒ ๋ฐฉ์ง
120- if ( ! post . is_end_time_set && endDate . getDate ( ) === now . getDate ( ) && endDate . getMonth ( ) === now . getMonth ( ) ) {
121- dDay = "D-0" ;
122- isTodayEnd = true ;
123- } else {
124- dDay = "๋ง๊ฐ" ;
125- isTodayEnd = false ;
126- }
118+ // ๐ด ์ด๋ฏธ ์๊ฐ์ด ์ง๋ ๊ฒฝ์ฐ โ ๋ฌด์กฐ๊ฑด ๋ง๊ฐ
119+ if ( endDate . getTime ( ) < now . getTime ( ) ) {
120+ dDay = "๋ง๊ฐ" ;
121+ isTodayEnd = false ;
127122 } else {
123+ // ์์ง ์ ์ง๋ ๊ฒฝ์ฐ โ ๋ ์ง ๋จ์ D-Day ๊ณ์ฐ
128124 const todayMidnight = new Date ( now . getFullYear ( ) , now . getMonth ( ) , now . getDate ( ) ) . getTime ( ) ;
129125 const endMidnight = new Date ( endDate . getFullYear ( ) , endDate . getMonth ( ) , endDate . getDate ( ) ) . getTime ( ) ;
130126 const diffDays = Math . ceil ( ( endMidnight - todayMidnight ) / ( 1000 * 60 * 60 * 24 ) ) ;
@@ -139,6 +135,8 @@ async function enrichDataWithMySQL(results, currentUserId = null) {
139135 }
140136 }
141137
138+
139+
142140 return {
143141 id : post . id ,
144142 title : post . title ,
@@ -208,18 +206,17 @@ const commonSort = [
208206 script : {
209207 lang : "painless" ,
210208 source : `
211- // end_date ์๋ ๊ฒฝ์ฐ โ ์์ (๊ทธ๋ฃน 2)
212- if (doc['end_date'].size() == 0) return 2;
209+ if (doc['end_date'].size() == 0) return 2; // ์์
213210
214211 long end = doc['end_date'].value.toInstant().toEpochMilli();
215212
216- // 1. ์ด๋ฏธ ๋ง๊ฐ๋ ๊ธ โ ๋งจ ๋ง์ง๋ง (๊ทธ๋ฃน 3)
213+ // ์ด๋ฏธ ๋ง๊ฐ
217214 if (end < params.now) return 3;
218215
219- // 2. ์ค๋(KST) ๋ง๊ฐ + ์์ง ์ ์ง๋ ๊ธ โ ์ต์ฐ์ (๊ทธ๋ฃน 0)
216+ // ์ค๋(KST) ๋ง๊ฐ ์์
220217 if (end >= params.dayStart && end <= params.dayEnd) return 0;
221218
222- // 3. ๊ทธ ์ธ ๋ฏธ๋ ๋ง๊ฐ โ ์ค๊ฐ (๊ทธ๋ฃน 1)
219+ // ๋ฏธ๋ ๋ง๊ฐ
223220 return 1;
224221 ` ,
225222 params : getSortParams ( )
@@ -228,9 +225,9 @@ const commonSort = [
228225 }
229226 } ,
230227
231- // ๐น 2์์: ๋ง๊ฐ ์ ๋ ๊ทธ๋ฃน๋ผ๋ฆฌ๋ "์์ฑ ์ค๋๋ ์ "
228+ // ๐น 2์์: ๊ฐ ๊ทธ๋ฃน ์์์ "์ต์ ๋ฑ๋ก์ "
232229 {
233- "created_at" : { "order" : "asc " }
230+ "created_at" : { "order" : "desc" , "missing" : "_last " }
234231 }
235232] ;
236233
0 commit comments