Skip to content
Draft
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
7 changes: 4 additions & 3 deletions app/models/streak_activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ def sync_for_user!(user)
project_keys = linked_projects.pluck(:name)
today = streak_date_for(Time.current, user.timezone)

start_date = if user.streak_synced_at
streak_date_for(user.streak_synced_at, user.timezone)
last_synced = user.try(:streak_synced_at)
start_date = if last_synced
streak_date_for(last_synced, user.timezone)
else
Date.parse(HackatimeService::START_DATE)
end
Expand All @@ -71,7 +72,7 @@ def sync_for_user!(user)
record.update!(coded_seconds: seconds)
end

user.update_column(:streak_synced_at, Time.current)
user.update_column(:streak_synced_at, Time.current) if user.has_attribute?(:streak_synced_at)
end

def streak_date_for(time, timezone)
Expand Down
2 changes: 1 addition & 1 deletion app/models/user/hackatime_project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class User::HackatimeProject < ApplicationRecord
private

def enqueue_streak_resync
user.update_column(:streak_synced_at, nil)
user.update_column(:streak_synced_at, nil) if user.has_attribute?(:streak_synced_at)
StreakSyncJob.perform_later(user_id)
end

Expand Down