volunteer-contributions-fetch 4.0.1 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,18 @@
1
1
  // Existing contributions are read from JSON and therefore have a string as
2
2
  // createdAt, while freshly fetched ones have a Date. Normalize before comparing.
3
+ // All fields a contribution carries are part of the key: some sources only
4
+ // provide day precision (e.g. community portal events at midnight), so
5
+ // distinct entries can share source, type, link and createdAt and only differ
6
+ // by description. JSON.stringify avoids ambiguity when a field contains the
7
+ // separator.
3
8
  function getContributionKey(contribution) {
4
- return [
9
+ return JSON.stringify([
5
10
  contribution.source,
6
11
  contribution.type,
7
12
  contribution.link,
8
13
  new Date(contribution.createdAt).getTime(),
9
- ].join('|');
14
+ contribution.description,
15
+ ]);
10
16
  }
11
17
 
12
18
  // Invalid dates would make the comparator return NaN, which leaves the sort
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "volunteer-contributions-fetch",
3
- "version": "4.0.1",
3
+ "version": "4.0.2",
4
4
  "description": "Library to fetch volunteer contributions from several sources such as GitHub",
5
5
  "author": "Michael Kohler",
6
6
  "license": "MIT",