Skip to content

Commit 95d38ab

Browse files
rjohnson2011claude
andcommitted
Fix timestamp updates and improve last_updated accuracy
- Fix hardcoded 'updating: true' to check actual refresh status - Use the more recent timestamp between cache and PR updates - Ensure last_updated reflects the most recent data change - Properly read refresh_status from cache to determine if updating This fixes the issue where the dashboard showed stale timestamps even when data was current. 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
1 parent c0030bb commit 95d38ab

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

app/controllers/api/v1/reviews_controller.rb

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,24 @@ def index
142142
github_service = GithubService.new(owner: repository_owner, repo: repository_name)
143143
rate_limit_info = github_service.rate_limit rescue nil
144144

145-
# Get the actual refresh completion time
146-
last_refresh_time = Rails.cache.read("last_refresh_time") || PullRequest.maximum(:updated_at)
145+
# Get the actual refresh completion time from cache
146+
cached_refresh_time = Rails.cache.read("last_refresh_time")
147+
148+
# Get the most recent PR update time for this repository
149+
recent_pr_update = PullRequest
150+
.where(repository_owner: repository_owner, repository_name: repository_name)
151+
.maximum(:updated_at)
152+
153+
# Use the more recent of the two timestamps
154+
last_refresh_time = if cached_refresh_time && recent_pr_update
155+
[cached_refresh_time, recent_pr_update].max
156+
else
157+
cached_refresh_time || recent_pr_update || Time.current
158+
end
159+
160+
# Check if actually updating
161+
refresh_status = Rails.cache.read("refresh_status") || {}
162+
is_updating = refresh_status[:updating] || false
147163

148164
render json: {
149165
pull_requests: open_pr_data,
@@ -152,7 +168,7 @@ def index
152168
approved_count: approved_pr_data.length,
153169
repository: "#{repository_owner}/#{repository_name}",
154170
last_updated: last_refresh_time,
155-
updating: true,
171+
updating: is_updating,
156172
rate_limit: rate_limit_info ? {
157173
remaining: rate_limit_info.remaining,
158174
limit: rate_limit_info.limit,

0 commit comments

Comments
 (0)