diff --git a/sharness/__snapshots__/example-github-load/data/sourcecred/example-github/github/view.json.gz b/sharness/__snapshots__/example-github-load/data/sourcecred/example-github/github/view.json.gz index 15fe3d8..f9f5c53 100644 Binary files a/sharness/__snapshots__/example-github-load/data/sourcecred/example-github/github/view.json.gz and b/sharness/__snapshots__/example-github-load/data/sourcecred/example-github/github/view.json.gz differ diff --git a/src/plugins/github/__snapshots__/relationalView.test.js.snap b/src/plugins/github/__snapshots__/relationalView.test.js.snap index d86d449..3a92dfc 100644 --- a/src/plugins/github/__snapshots__/relationalView.test.js.snap +++ b/src/plugins/github/__snapshots__/relationalView.test.js.snap @@ -20,6 +20,7 @@ exports[`plugins/github/relationalView Comment has reactions 1`] = ` Array [ Object { "content": "THUMBS_UP", + "timestampMs": 1537294753000, "user": Object { "login": "wchargin", "subtype": "USER", @@ -28,6 +29,7 @@ Array [ }, Object { "content": "THUMBS_DOWN", + "timestampMs": 1537294755000, "user": Object { "login": "wchargin", "subtype": "USER", @@ -36,6 +38,7 @@ Array [ }, Object { "content": "THUMBS_UP", + "timestampMs": 1537294756000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -44,6 +47,7 @@ Array [ }, Object { "content": "LAUGH", + "timestampMs": 1537294757000, "user": Object { "login": "wchargin", "subtype": "USER", @@ -52,6 +56,7 @@ Array [ }, Object { "content": "THUMBS_DOWN", + "timestampMs": 1537294757000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -60,6 +65,7 @@ Array [ }, Object { "content": "HOORAY", + "timestampMs": 1537294758000, "user": Object { "login": "wchargin", "subtype": "USER", @@ -68,6 +74,7 @@ Array [ }, Object { "content": "LAUGH", + "timestampMs": 1537294759000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -76,6 +83,7 @@ Array [ }, Object { "content": "CONFUSED", + "timestampMs": 1537294760000, "user": Object { "login": "wchargin", "subtype": "USER", @@ -84,6 +92,7 @@ Array [ }, Object { "content": "HOORAY", + "timestampMs": 1537294761000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -92,6 +101,7 @@ Array [ }, Object { "content": "HEART", + "timestampMs": 1537294762000, "user": Object { "login": "wchargin", "subtype": "USER", @@ -100,6 +110,7 @@ Array [ }, Object { "content": "CONFUSED", + "timestampMs": 1537294762000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -108,6 +119,7 @@ Array [ }, Object { "content": "HEART", + "timestampMs": 1537294764000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -409,6 +421,7 @@ Object { "https://github.com/sourcecred/example-github/issues/1": Array [ Object { "content": "LAUGH", + "timestampMs": 1536878099000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -417,6 +430,7 @@ Object { }, Object { "content": "HEART", + "timestampMs": 1536878100000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -427,6 +441,7 @@ Object { "https://github.com/sourcecred/example-github/issues/11#issuecomment-420813206": Array [ Object { "content": "THUMBS_UP", + "timestampMs": 1536952413000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -435,6 +450,7 @@ Object { }, Object { "content": "THUMBS_DOWN", + "timestampMs": 1536952415000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -443,6 +459,7 @@ Object { }, Object { "content": "LAUGH", + "timestampMs": 1536952417000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -451,6 +468,7 @@ Object { }, Object { "content": "HOORAY", + "timestampMs": 1536952420000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -461,6 +479,7 @@ Object { "https://github.com/sourcecred/example-github/issues/12": Array [ Object { "content": "THUMBS_UP", + "timestampMs": 1536878091000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -471,6 +490,7 @@ Object { "https://github.com/sourcecred/example-github/issues/13": Array [ Object { "content": "THUMBS_UP", + "timestampMs": 1536878140000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -479,6 +499,7 @@ Object { }, Object { "content": "THUMBS_DOWN", + "timestampMs": 1536878142000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -487,6 +508,7 @@ Object { }, Object { "content": "LAUGH", + "timestampMs": 1536878143000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -495,6 +517,7 @@ Object { }, Object { "content": "HOORAY", + "timestampMs": 1536878144000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -503,6 +526,7 @@ Object { }, Object { "content": "CONFUSED", + "timestampMs": 1536878147000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -511,6 +535,7 @@ Object { }, Object { "content": "HEART", + "timestampMs": 1536878149000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -519,6 +544,7 @@ Object { }, Object { "content": "ROCKET", + "timestampMs": 1548353975000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -527,6 +553,7 @@ Object { }, Object { "content": "EYES", + "timestampMs": 1548353977000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -537,6 +564,7 @@ Object { "https://github.com/sourcecred/example-github/pull/5#discussion_r171460198": Array [ Object { "content": "THUMBS_UP", + "timestampMs": 1537294753000, "user": Object { "login": "wchargin", "subtype": "USER", @@ -545,6 +573,7 @@ Object { }, Object { "content": "THUMBS_DOWN", + "timestampMs": 1537294755000, "user": Object { "login": "wchargin", "subtype": "USER", @@ -553,6 +582,7 @@ Object { }, Object { "content": "THUMBS_UP", + "timestampMs": 1537294756000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -561,6 +591,7 @@ Object { }, Object { "content": "LAUGH", + "timestampMs": 1537294757000, "user": Object { "login": "wchargin", "subtype": "USER", @@ -569,6 +600,7 @@ Object { }, Object { "content": "THUMBS_DOWN", + "timestampMs": 1537294757000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -577,6 +609,7 @@ Object { }, Object { "content": "HOORAY", + "timestampMs": 1537294758000, "user": Object { "login": "wchargin", "subtype": "USER", @@ -585,6 +618,7 @@ Object { }, Object { "content": "LAUGH", + "timestampMs": 1537294759000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -593,6 +627,7 @@ Object { }, Object { "content": "CONFUSED", + "timestampMs": 1537294760000, "user": Object { "login": "wchargin", "subtype": "USER", @@ -601,6 +636,7 @@ Object { }, Object { "content": "HOORAY", + "timestampMs": 1537294761000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -609,6 +645,7 @@ Object { }, Object { "content": "HEART", + "timestampMs": 1537294762000, "user": Object { "login": "wchargin", "subtype": "USER", @@ -617,6 +654,7 @@ Object { }, Object { "content": "CONFUSED", + "timestampMs": 1537294762000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -625,6 +663,7 @@ Object { }, Object { "content": "HEART", + "timestampMs": 1537294764000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -635,6 +674,7 @@ Object { "https://github.com/sourcecred/example-github/pull/5#issuecomment-396430464": Array [ Object { "content": "HEART", + "timestampMs": 1536952482000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -643,6 +683,7 @@ Object { }, Object { "content": "CONFUSED", + "timestampMs": 1536952484000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -653,6 +694,7 @@ Object { "https://github.com/sourcecred/example-github/pull/9": Array [ Object { "content": "HEART", + "timestampMs": 1536952427000, "user": Object { "login": "decentralion", "subtype": "USER", @@ -661,6 +703,7 @@ Object { }, Object { "content": "THUMBS_UP", + "timestampMs": 1536952428000, "user": Object { "login": "decentralion", "subtype": "USER", diff --git a/src/plugins/github/example/example-github.json b/src/plugins/github/example/example-github.json index 3e7f88d..cd24792 100644 --- a/src/plugins/github/example/example-github.json +++ b/src/plugins/github/example/example-github.json @@ -153,6 +153,7 @@ { "__typename": "Reaction", "content": "LAUGH", + "createdAt": "2018-09-13T22:34:59Z", "id": "MDg6UmVhY3Rpb24yOTQwMjEwNw==", "user": { "__typename": "User", @@ -164,6 +165,7 @@ { "__typename": "Reaction", "content": "HEART", + "createdAt": "2018-09-13T22:35:00Z", "id": "MDg6UmVhY3Rpb24yOTQwMjEwOQ==", "user": { "__typename": "User", @@ -515,6 +517,7 @@ { "__typename": "Reaction", "content": "THUMBS_UP", + "createdAt": "2018-09-14T19:13:33Z", "id": "MDg6UmVhY3Rpb24yOTQ1MDk5Nw==", "user": { "__typename": "User", @@ -526,6 +529,7 @@ { "__typename": "Reaction", "content": "THUMBS_DOWN", + "createdAt": "2018-09-14T19:13:35Z", "id": "MDg6UmVhY3Rpb24yOTQ1MTAwMQ==", "user": { "__typename": "User", @@ -537,6 +541,7 @@ { "__typename": "Reaction", "content": "LAUGH", + "createdAt": "2018-09-14T19:13:37Z", "id": "MDg6UmVhY3Rpb24yOTQ1MTAwMw==", "user": { "__typename": "User", @@ -548,6 +553,7 @@ { "__typename": "Reaction", "content": "HOORAY", + "createdAt": "2018-09-14T19:13:40Z", "id": "MDg6UmVhY3Rpb24yOTQ1MTAwOA==", "user": { "__typename": "User", @@ -601,6 +607,7 @@ { "__typename": "Reaction", "content": "THUMBS_UP", + "createdAt": "2018-09-13T22:34:51Z", "id": "MDg6UmVhY3Rpb24yOTQwMjEwMw==", "user": { "__typename": "User", @@ -631,6 +638,7 @@ { "__typename": "Reaction", "content": "THUMBS_UP", + "createdAt": "2018-09-13T22:35:40Z", "id": "MDg6UmVhY3Rpb24yOTQwMjEzNA==", "user": { "__typename": "User", @@ -642,6 +650,7 @@ { "__typename": "Reaction", "content": "THUMBS_DOWN", + "createdAt": "2018-09-13T22:35:42Z", "id": "MDg6UmVhY3Rpb24yOTQwMjEzOQ==", "user": { "__typename": "User", @@ -653,6 +662,7 @@ { "__typename": "Reaction", "content": "LAUGH", + "createdAt": "2018-09-13T22:35:43Z", "id": "MDg6UmVhY3Rpb24yOTQwMjE0MA==", "user": { "__typename": "User", @@ -664,6 +674,7 @@ { "__typename": "Reaction", "content": "HOORAY", + "createdAt": "2018-09-13T22:35:44Z", "id": "MDg6UmVhY3Rpb24yOTQwMjE0MQ==", "user": { "__typename": "User", @@ -675,6 +686,7 @@ { "__typename": "Reaction", "content": "CONFUSED", + "createdAt": "2018-09-13T22:35:47Z", "id": "MDg6UmVhY3Rpb24yOTQwMjE0NQ==", "user": { "__typename": "User", @@ -686,6 +698,7 @@ { "__typename": "Reaction", "content": "HEART", + "createdAt": "2018-09-13T22:35:49Z", "id": "MDg6UmVhY3Rpb24yOTQwMjE0OA==", "user": { "__typename": "User", @@ -697,6 +710,7 @@ { "__typename": "Reaction", "content": "ROCKET", + "createdAt": "2019-01-24T18:19:35Z", "id": "MDg6UmVhY3Rpb24zNTc5ODQzNQ==", "user": { "__typename": "User", @@ -708,6 +722,7 @@ { "__typename": "Reaction", "content": "EYES", + "createdAt": "2019-01-24T18:19:37Z", "id": "MDg6UmVhY3Rpb24zNTc5ODQ0Mg==", "user": { "__typename": "User", @@ -869,6 +884,7 @@ { "__typename": "Reaction", "content": "HEART", + "createdAt": "2018-09-14T19:14:42Z", "id": "MDg6UmVhY3Rpb24yOTQ1MTA1Mw==", "user": { "__typename": "User", @@ -880,6 +896,7 @@ { "__typename": "Reaction", "content": "CONFUSED", + "createdAt": "2018-09-14T19:14:44Z", "id": "MDg6UmVhY3Rpb24yOTQ1MTA1NQ==", "user": { "__typename": "User", @@ -1019,6 +1036,7 @@ { "__typename": "Reaction", "content": "THUMBS_UP", + "createdAt": "2018-09-18T18:19:13Z", "id": "MDg6UmVhY3Rpb24yOTU5NTI1MQ==", "user": { "__typename": "User", @@ -1030,6 +1048,7 @@ { "__typename": "Reaction", "content": "THUMBS_DOWN", + "createdAt": "2018-09-18T18:19:15Z", "id": "MDg6UmVhY3Rpb24yOTU5NTI1NA==", "user": { "__typename": "User", @@ -1041,6 +1060,7 @@ { "__typename": "Reaction", "content": "THUMBS_UP", + "createdAt": "2018-09-18T18:19:16Z", "id": "MDg6UmVhY3Rpb24yOTU5NTI1NQ==", "user": { "__typename": "User", @@ -1052,6 +1072,7 @@ { "__typename": "Reaction", "content": "LAUGH", + "createdAt": "2018-09-18T18:19:17Z", "id": "MDg6UmVhY3Rpb24yOTU5NTI1Nw==", "user": { "__typename": "User", @@ -1063,6 +1084,7 @@ { "__typename": "Reaction", "content": "THUMBS_DOWN", + "createdAt": "2018-09-18T18:19:17Z", "id": "MDg6UmVhY3Rpb24yOTU5NTI1OA==", "user": { "__typename": "User", @@ -1074,6 +1096,7 @@ { "__typename": "Reaction", "content": "HOORAY", + "createdAt": "2018-09-18T18:19:18Z", "id": "MDg6UmVhY3Rpb24yOTU5NTI1OQ==", "user": { "__typename": "User", @@ -1085,6 +1108,7 @@ { "__typename": "Reaction", "content": "LAUGH", + "createdAt": "2018-09-18T18:19:19Z", "id": "MDg6UmVhY3Rpb24yOTU5NTI2MQ==", "user": { "__typename": "User", @@ -1096,6 +1120,7 @@ { "__typename": "Reaction", "content": "CONFUSED", + "createdAt": "2018-09-18T18:19:20Z", "id": "MDg6UmVhY3Rpb24yOTU5NTI2NQ==", "user": { "__typename": "User", @@ -1107,6 +1132,7 @@ { "__typename": "Reaction", "content": "HOORAY", + "createdAt": "2018-09-18T18:19:21Z", "id": "MDg6UmVhY3Rpb24yOTU5NTI2Ng==", "user": { "__typename": "User", @@ -1118,6 +1144,7 @@ { "__typename": "Reaction", "content": "HEART", + "createdAt": "2018-09-18T18:19:22Z", "id": "MDg6UmVhY3Rpb24yOTU5NTI2OA==", "user": { "__typename": "User", @@ -1129,6 +1156,7 @@ { "__typename": "Reaction", "content": "CONFUSED", + "createdAt": "2018-09-18T18:19:22Z", "id": "MDg6UmVhY3Rpb24yOTU5NTI2OQ==", "user": { "__typename": "User", @@ -1140,6 +1168,7 @@ { "__typename": "Reaction", "content": "HEART", + "createdAt": "2018-09-18T18:19:24Z", "id": "MDg6UmVhY3Rpb24yOTU5NTI3NA==", "user": { "__typename": "User", @@ -1198,6 +1227,7 @@ { "__typename": "Reaction", "content": "HEART", + "createdAt": "2018-09-14T19:13:47Z", "id": "MDg6UmVhY3Rpb24yOTQ1MTAxMg==", "user": { "__typename": "User", @@ -1209,6 +1239,7 @@ { "__typename": "Reaction", "content": "THUMBS_UP", + "createdAt": "2018-09-14T19:13:48Z", "id": "MDg6UmVhY3Rpb24yOTQ1MTAxNA==", "user": { "__typename": "User", diff --git a/src/plugins/github/graphqlTypes.js b/src/plugins/github/graphqlTypes.js index a89618b..b354333 100644 --- a/src/plugins/github/graphqlTypes.js +++ b/src/plugins/github/graphqlTypes.js @@ -133,6 +133,7 @@ export const PullRequestReviewState$Values: {| export type Reaction = {| +__typename: "Reaction", +content: ReactionContent, + +createdAt: DateTime, +id: string, +user: null | User, |}; diff --git a/src/plugins/github/relationalView.js b/src/plugins/github/relationalView.js index bdc4d56..bc0614e 100644 --- a/src/plugins/github/relationalView.js +++ b/src/plugins/github/relationalView.js @@ -492,7 +492,8 @@ export class RelationalView { `Invariant violation: Reaction with id ${json.id} did not have 1 author` ); } - return {content: json.content, user: authorAddresses[0]}; + const timestampMs = +new Date(json.createdAt); + return {content: json.content, user: authorAddresses[0], timestampMs}; } _addNullableAuthor(json: null | T.Actor): UserlikeAddress[] { @@ -692,6 +693,7 @@ export class RelationalView { type ReactionRecord = {| +content: T.ReactionContent, +user: UserlikeAddress, + +timestampMs: number, |}; type Entry = diff --git a/src/plugins/github/schema.js b/src/plugins/github/schema.js index 6a38f86..8e5e7c4 100644 --- a/src/plugins/github/schema.js +++ b/src/plugins/github/schema.js @@ -93,6 +93,7 @@ export default function schema(): Schema.Schema { id: s.id(), content: s.primitive(s.nonNull("ReactionContent")), user: s.node("User"), + createdAt: s.primitive(s.nonNull("DateTime")), }), Ref: s.object({ id: s.id(),