Open merlinorg opened 2 years ago
drop table dups;
create table dups(id bigint) as (select max(id) as id from rides group by athlete_id, floor(unix_timestamp(start_date)/300) having count(*) > 1);
delete from ride_weather using ride_weather left join dups on dups.id = ride_weather.ride_id where dups.id is not null;
delete from ride_efforts using ride_efforts left join dups on dups.id = ride_efforts.ride_id where dups.id is not null;
delete from rides using rides left join dups on dups.id = rides.id where dups.id is not null;
mysql> create table dups(id bigint) as (select max(id) as id from rides group by athlete_id, floor(unix_timestamp(start_date)/300) having count(*) > 1);
Query OK, 45 rows affected (0.07 sec)
Records: 45 Duplicates: 0 Warnings: 0
mysql> delete from ride_weather using ride_weather left join dups on dups.id = ride_weather.ride_id where dups.id is not null;
Query OK, 43 rows affected (0.40 sec)
mysql> delete from ride_efforts using ride_efforts left join dups on dups.id = ride_efforts.ride_id where dups.id is not null;
Query OK, 1347 rows affected (0.07 sec)
mysql> delete from rides using rides left join dups on dups.id = rides.id where dups.id is not null;
Query OK, 45 rows affected (0.02 sec)
Some athletes routinely ride "with" themself. I suspect using both computer and phone to track ride. These get recorded as separate rides in FS.
Crudely bucketing by 5 minute start time we see...