Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ public Map<String, Object> fetchEvents(String accessToken, LocalDateTime lastSyn
headers.setBearerAuth(accessToken);
HttpEntity<Void> request = new HttpEntity<>(headers);

String uriTemplate = calendarApiUrl + "?timeMin={timeMin}&timeMax={timeMax}&singleEvents=true&showDeleted=true";
String uriTemplate = calendarApiUrl + "?singleEvents=true&showDeleted=true";
List<Object> uriVariables = new java.util.ArrayList<>();
uriVariables.add(timeMin.toInstant().toString());
uriVariables.add(timeMax.toInstant().toString());

if (lastSyncedAt != null) {
// ๋งˆ์ง€๋ง‰ ๋™๊ธฐํ™” ์‹œ๊ฐ„ ์ดํ›„์— ๋ณ€๊ฒฝ๋œ ๋ฐ์ดํ„ฐ๋งŒ ์š”์ฒญ (updatedMin)
// ์ฆ๋ถ„ ๋™๊ธฐํ™” ์‹œ timeMin/timeMax ํ•„ํ„ฐ๋ฅผ ์ œ์™ธํ•ด์•ผ ๊ตฌ๊ธ€์ด ์‚ญ์ œ๋œ(cancelled) ์ผ์ •์„ ๋ณด๋‚ด์ค๋‹ˆ๋‹ค.
String updatedMin = lastSyncedAt.atZone(ZoneId.of("Asia/Seoul")).toInstant().toString();
uriTemplate += "&updatedMin={updatedMin}";
uriVariables.add(updatedMin);
} else {
// ์ตœ์ดˆ ๋™๊ธฐํ™”
uriTemplate += "&orderBy=startTime";
// ์ตœ์ดˆ Full ๋™๊ธฐํ™” ์‹œ์—๋Š” ํ•ด๋‹น ์—ฐ๋„ ๋ฐ์ดํ„ฐ๋งŒ ๊ฐ€์ ธ์˜ค๋„๋ก ๋ฒ”์œ„ ์ง€์ •
uriTemplate += "&timeMin={timeMin}&timeMax={timeMax}&orderBy=startTime";
uriVariables.add(timeMin.toInstant().toString());
uriVariables.add(timeMax.toInstant().toString());
}

// ํŽ˜์ด์ง€๋„ค์ด์…˜ ํ† ํฐ์ด ์กด์žฌํ•˜๋ฉด ์ฟผ๋ฆฌ ํŒŒ๋ผ๋ฏธํ„ฐ ์ถ”๊ฐ€
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- V20: ๊ณตํœด์ผ ๋‹ค์ค‘ ์„œ๋ฒ„ ๋™์‹œ์„ฑ(Race Condition) ์ค‘๋ณต ์‚ฝ์ž… ๋ฐฉ์–ด ๋กœ์ง ์ถ”๊ฐ€

-- 1. ์ค‘๋ณต๋œ ๋ฐ์ดํ„ฐ๊ฐ€ ๋‚จ์•„์žˆ์œผ๋ฉด Unique Index ์ƒ์„ฑ์ด ์‹คํŒจํ•˜๋ฏ€๋กœ, ๊ธฐ์กด ๊ณตํœด์ผ ๋ฐ์ดํ„ฐ๋ฅผ ๊น”๋”ํ•˜๊ฒŒ ์ดˆ๊ธฐํ™”
DELETE FROM events WHERE source_type = 'HOLIDAY';

-- 2. DB ๋ ˆ๋ฒจ์—์„œ '๋™์ผํ•œ ์™ธ๋ถ€ ๊ณตํœด์ผ ID'๊ฐ€ 2๋ฒˆ ๋“ค์–ด์˜ค๋Š” ๊ฒƒ์„ ์›์ฒœ ์ฐจ๋‹จํ•˜๋Š” ๋ฐฉ์–ด๋ง‰ ์ƒ์„ฑ
CREATE UNIQUE INDEX uq_events_holiday_external_id
ON events (external_event_id)
WHERE source_type = 'HOLIDAY';
Loading