salamanders / pledgejs

pledge.js shows how much you have been contributing to shared documents
https://pledgejs.appspot.com
Apache License 2.0
17 stars 2 forks source link

Undefined authors cause low percentYou #16

Open DerSaidin opened 2 years ago

DerSaidin commented 2 years ago

I noticed my PercentYou was much lower than it should be on some docs I wrote (~15% when I'd expect >95%).

counts[fileId] data looks like this

[
    // ...
    {
        "type": "comment",
        "ts": "2022-01-14T08:57:09.182Z"
    },
    {
        "type": "reply",
        "ts": "2022-01-25T18:30:53.472Z"
    },
    {
        "type": "reply",
        "ts": "2022-02-03T21:31:29.779Z"
    },
    {
        "type": "revision",
        "author": "me@myemail.com",
        "ts": "2022-02-11T11:34:34.428Z"
    },
    {
        "type": "revision",
        "author": "me@myemail.com",
        "ts": "2022-02-11T18:30:40.879Z"
    },
    // ...
]

The missing "author" fields on many edit objects cause the contributors counts to look like this

{"undefined":88,"me@myemail.com":20}

The best fix would be to get the correct author data.

If we cannot get the correct author data, would it make sense to skip counting edits changes with undefined author (particularly when they're only comment/reply)? ie. in this case 20/20 => 100%, instead of 20/(88+20) => 18%