-
Notifications
You must be signed in to change notification settings - Fork 0
[EDMT-452] 커스텀 메트릭 정합성 문제 해결 #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
1870bfa
[fix] enable AspectJ auto proxy support in EdukitApiApplication
wldks1008 9c5288e
[refac] refactor AI generation logic to retrieve student record type …
wldks1008 9353b94
[refac] rename StudentRecordMetricsService to StudentRecordMetricsCou…
wldks1008 bbc2d47
[refac] rename GenerationTrackingService to RecordGenerationTracker a…
wldks1008 f3e8c6d
[fix] update argument count in collectAIGenerationMetrics method to s…
wldks1008 fc34d71
[fix] retrieve StudentRecordType from StudentRecord in collectComplet…
wldks1008 ba89e2e
[fix] update argument count in collectCompletionMetrics method to ref…
wldks1008 2f48fe9
[fix] retrieve StudentRecordType from StudentRecord in StudentRecordM…
wldks1008 beb2ff0
[fix] refactor RecordGenerationTracker to use Redis for generation co…
wldks1008 5291966
[refac] refactor isFirstGeneration method to use Lua script for atomi…
wldks1008 c935527
[fix] update RecordGenerationTracker to use configurable TTL for Redi…
wldks1008 63e4b97
[refac] update Lua script in RecordGenerationTracker to conditionally…
wldks1008 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 0 additions & 56 deletions
56
...t-core/src/main/java/com/edukit/core/studentrecord/service/GenerationTrackingService.java
This file was deleted.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
edukit-core/src/main/java/com/edukit/core/studentrecord/service/RecordGenerationTracker.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| package com.edukit.core.studentrecord.service; | ||
|
|
||
| import java.util.Collections; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.beans.factory.annotation.Value; | ||
| import org.springframework.data.redis.core.StringRedisTemplate; | ||
| import org.springframework.data.redis.core.script.DefaultRedisScript; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Slf4j | ||
| @Component | ||
| @RequiredArgsConstructor | ||
| public class RecordGenerationTracker { | ||
|
|
||
| @Value("${record.generation.ttl}") | ||
| private long ttlSeconds; | ||
|
|
||
| private static final String KEY_PREFIX = "sr:gen:"; | ||
| private static final String LUA_SCRIPT = | ||
| "local ttl = tonumber(ARGV[1]) or 0 " + | ||
| "local c = redis.call('INCR', KEYS[1]) " + | ||
| "if c == 1 and ttl > 0 then " + | ||
| " redis.call('EXPIRE', KEYS[1], ttl) " + | ||
| "end " + | ||
| "return c"; | ||
|
|
||
| private static final DefaultRedisScript<Long> INCR_EXPIRE_SCRIPT; | ||
|
|
||
|
|
||
| static { | ||
| DefaultRedisScript<Long> script = new DefaultRedisScript<>(); | ||
| script.setScriptText(LUA_SCRIPT); | ||
| script.setResultType(Long.class); | ||
| INCR_EXPIRE_SCRIPT = script; | ||
| } | ||
|
|
||
| private final StringRedisTemplate redisTemplate; | ||
|
|
||
| public boolean isFirstGeneration(long recordId) { | ||
| String key = getCountKey(recordId); | ||
| Long newCount = redisTemplate.execute( | ||
| INCR_EXPIRE_SCRIPT, | ||
| Collections.singletonList(key), | ||
| String.valueOf(ttlSeconds) | ||
| ); | ||
|
|
||
| if (newCount == null) { | ||
| log.warn("Redis script returned null for key: {}", key); | ||
| return false; | ||
| } | ||
|
|
||
| boolean isFirst = newCount == 1L; | ||
| if (isFirst) { | ||
| log.debug("RecordId: {}, Generation count set to 1 (first)", recordId); | ||
| } else { | ||
| log.debug("RecordId: {}, Generation count: {} (regeneration)", recordId, newCount); | ||
| } | ||
| return isFirst; | ||
| } | ||
|
|
||
| private String getCountKey(long recordId) { | ||
| return KEY_PREFIX + recordId + ":count"; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.