Skip to content

Commit c911257

Browse files
authored
Merge pull request #119 from Solux-WebBeing/fix/imminent
๊บผ์ ธ๊บผ์ ธ!
2 parents 09a0ea7 + a1c0947 commit c911257

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

โ€Žbackend/src/controllers/search.controller.jsโ€Ž

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
ย (0)