RaspberryPiFoundation / editor-ui

Code Editor web component
https://editor-static.raspberrypi.org
Apache License 2.0
36 stars 9 forks source link

Dupe student user remixes #1128

Open danhalson opened 2 days ago

danhalson commented 2 days ago

This is an issue in staging that @MFarringtonRPF observed, which led to a second remix being erroneously created for a user, and one of them not displaying user details on the Student Work page. There is a chance that old data might have a part in it.

The ids of Mel's projects where the issue was observed:

student_id (with dupe HTML projs): 5f3e56b7-9dc6-482a-a791-489ae4aa7f7d
school_id: d5f53eca-0b12-475a-9ef9-b4f5b4ddb250

This query shows possible further scenarios where this has been seen in prod:

SELECT 
    school_id, 
    user_id, 
    remixed_from_id, 
    project_type, 
    COUNT(*) AS remix_count,
    MIN(created_at) AS earliest_created_at,
    MAX(created_at) AS latest_created_at
FROM projects
WHERE school_id IS NOT NULL AND lesson_id IS NULL
GROUP BY school_id, user_id, remixed_from_id, project_type
HAVING COUNT(*) > 1;

Example problem records:

id, user_id, name, identifier, project_type, created_at, updated_at, remixed_from_id, locale, remix_origin, school_id, lesson_id, finished
96acbc0a-481e-4c6b-919e-c40db9c3a59a    9367a560-c3cb-470c-8c57-aac428e1c5a3    U1AQ5   recap-slept-enter   python  2024-10-17 08:15:58.430802  2024-10-17 08:15:58.430802  bf667646-5817-4fe4-a0d2-981b5d6a706f        https://editor.raspberrypi.org  9d2e4cc3-698a-46f5-a852-ad0fc257bd2c        
7ca2ad7c-2857-4636-8c5d-5b99501ff876    9367a560-c3cb-470c-8c57-aac428e1c5a3    U1AQ5   perky-iron-half python  2024-10-17 08:24:01.284243  2024-10-17 08:24:01.284243  bf667646-5817-4fe4-a0d2-981b5d6a706f        https://editor.raspberrypi.org  9d2e4cc3-698a-46f5-a852-ad0fc257bd2c    

Logs:

First remix: https://logs.betterstack.com/team/54242/tail?s=314882&q=recap-slept-enter Second remix: https://logs.betterstack.com/team/54242/tail?s=314882&q=perky-iron-half

danhalson commented 2 days ago

@sra405 I've added all I know here, but if you could flesh it out with any further info, that would be great

create-issue-branch[bot] commented 2 days ago

Branch issues/1128-Dupe_student_user_remixes created!

MFarringtonRPF commented 1 day ago

Staging - Plum School - Project name: Hello World: Basic HTML

Image

loiswells97 commented 1 day ago

So far: managed to fix displaying the student names if there are duplicate students, but still unsure why multiple remixes are being created

loiswells97 commented 1 day ago

Looks like the get request for the remix when the project is revisited isn't happening, it sends a get request for the original project instead. Then when the user clicks save, it successfully remixes the original project again, but does a get for the first remix and returns that.

e.g. https://telemetry.betterstack.com/team/54242/tail?s=314882&q=lyric-dent-math with remixes at 2024-10-24 13:51:10.32 and 2024-10-24 13:53:42.63