Skip to content

Commit 5e0f6b5

Browse files
authored
Merge pull request #144 from Solux-WebBeing/fix/imminent
update cronjob
2 parents 5655e56 + e360824 commit 5e0f6b5

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed
Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,22 @@ const buildScript = (group) => ({
3939
source: `
4040
ctx._source.sort_group = params.group;
4141

42-
// sort_end๋Š” end_date ๊ธฐ์ค€ epoch millis๋กœ ํ†ต์ผ
43-
if (doc['end_date'].size() != 0) {
44-
ctx._source.sort_end = doc['end_date'].value.toInstant().toEpochMilli();
42+
// sort_end๋Š” end_date ๊ธฐ์ค€ epoch millis๋กœ ํ†ต์ผ (updateByQuery์—์„œ๋Š” doc[] ์‚ฌ์šฉ ๋ถˆ๊ฐ€)
43+
if (ctx._source.containsKey('end_date') && ctx._source.end_date != null) {
44+
def v = ctx._source.end_date;
45+
46+
// end_date๊ฐ€ ์ˆซ์ž(epoch millis)์ธ ๊ฒฝ์šฐ
47+
if (v instanceof Number) {
48+
ctx._source.sort_end = ((Number)v).longValue();
49+
50+
// end_date๊ฐ€ ISO ๋ฌธ์ž์—ด(์˜ˆ: 2026-02-20T14:00:00.000Z)์ธ ๊ฒฝ์šฐ
51+
} else if (v instanceof String) {
52+
ctx._source.sort_end = java.time.Instant.parse((String)v).toEpochMilli();
53+
54+
// ๊ธฐํƒ€ ์˜ˆ์™ธ ์ผ€์ด์Šค๋Š” ๋’ค๋กœ ๋ณด๋ƒ„
55+
} else {
56+
ctx._source.sort_end = 9223372036854775807L;
57+
}
4558
} else {
4659
ctx._source.sort_end = 9223372036854775807L; // ์ƒ์‹œ(์—†์Œ)๋Š” ๋งจ ๋’ค๋กœ
4760
}
@@ -77,14 +90,17 @@ async function reclassifySortGroups() {
7790
console.log("[range] now=", nowIso);
7891
console.log("[range] kstToday(UTC) start=", utcStartIso, "end=", utcEndIso);
7992

93+
// 1) ์ƒ์‹œ(2): end_date ์—†์Œ
8094
// 1) ์ƒ์‹œ(2): end_date ์—†์Œ
8195
await updateGroup({
8296
name: "ALWAYS(2)",
8397
group: 2,
8498
query: {
8599
bool: {
86-
must_not: [{ exists: { field: "end_date" } }],
87-
must_not: [{ term: { sort_group: 2 } }],
100+
must_not: [
101+
{ exists: { field: "end_date" } },
102+
{ term: { sort_group: 2 } },
103+
],
88104
},
89105
},
90106
});

0 commit comments

Comments
ย (0)