dblock / slack-strava

(Re)Post Strava activities to Slack
https://slava.playplay.io
MIT License
37 stars 6 forks source link

long ride not showing up in channel #85

Closed dmca-faire closed 4 years ago

dmca-faire commented 4 years ago

My last 2 big rides didn't show up on our channel. I manually checked and all other rides posted in our Strava group were synced to the slack channel. My other, shorter rides were also synced. I am wondering if this has anything to do with the size of the ride file.

https://www.strava.com/activities/3286118305 https://www.strava.com/activities/3318422565

dblock commented 4 years ago

Looks like we're missing activities. Likely because a single sync is asking for 10 latest.

Catch up script, found at least two dozen across all clubs:

Club.connected_to_strava.each do |club|
  begin
    puts club.to_s
    current_page = 1
    while current_page < 3
      club.strava_client.club_activities(club.strava_id, page: current_page, per_page: 10).each do |activity|
        begin
          next if Activity.where(
            name: activity.name,
            distance: activity.distance, 
            moving_time: activity.moving_time, 
            elapsed_time: activity.elapsed_time, 
            total_elevation_gain: activity.total_elevation_gain
          ).exists?

          puts "#{activity.name}: missing"

          club_activity = ClubActivity.new(ClubActivity.attrs_from_strava(activity).merge(team: club.team, club: club))
          next if ClubActivity.where(strava_id: club_activity.strava_id).exists?
          club_activity.save!
        rescue Exception => e
          puts e.message
        end
      end
      current_page += 1
    end
  rescue Exception => e
    puts e.message
  end
end
dblock commented 4 years ago

I believe I have fixed this @dmca-faire, thank you for reporting it. Please do let me know if this happens again.

dblock commented 4 years ago

For future debugging: user id = 5e1523da0a005e010235b3de, club id = 5e1524210a005e010235b3ec

dmca-faire commented 4 years ago

Thanks, @dblock!