 
 
 # Go through the activity table of the notifications_syncdb database, if it is loaded,
-# and ensure that there is at most one entry with each project_id/path.  If there are
+# and ensure that there is at most one entry with each user_id/project_id/path.  If there are
 # multiple entries with the same project_id/path, delete all but the one with the
 # newest timestamp. After fixes, returns list of all notifications.
 # Also, if any timestamp is in the future, set it to now.

        all.push(x)
    for key, timestamps of seen_so_far
        if timestamps.length > 1
            console.log("DUPLICATE! ", key, timestamps)
            all = undefined
            timestamps.sort()
            for timestamp in timestamps.slice(0, timestamps.length-1)
                notifications_syncdb.delete
                    where :
                        project_id : key.slice(0,36)
                        path       : key.slice(36)
                        timestamp  : timestamp
            timestamps = timestamps.slice(timestamps.length-1)
        # now only one timestamp
        if timestamps[0] > now or not timestamps[0]  # null or in the future? -- corruption/weirdness (or browser is bad...?)
            #console.log("TIMESTAMP in future -- fixing ", key, timestamps)
            all = undefined
            update_db
                set :
                    timestamp  : now
                where :
                    project_id : key.slice(0,36)
                    path       : key.slice(36)

    if not all?
        # had a marge conflict so reload

    all = []
    now = new Date() - 0
    for x in notifications_syncdb.select(where:{table:'activity'})
        key = "#{x.project_id}#{x.user_id}#{x.path}"
        v = seen_so_far[key]
        if not v?
            seen_so_far[key] = [x.timestamp]
