Commit 2bf1394722753ed8aff3228422571438b98fe96f
Add userId property
cel committed on 12/1/2019, 4:12:53 AMParent: 3f6da406d8217032f93b552b50bee8ca2384591a
Files changed
README.md | changed |
bin.js | changed |
README.md | |||
---|---|---|---|
@@ -26,8 +26,9 @@ | |||
26 | 26 … | - Property "site" refers to the Wikimedia site base URL. | |
27 | 27 … | - Property `pageId` is a [denormalization](https://en.wikipedia.org/wiki/Denormalization) used to facilitate querying SSB for an article. It is the SSB blob hash of the values for the site property and title property, separated by a tab ("\t"). | |
28 | 28 … | - Content ("*" property in revision slots) is replaced with the id of the SSB blob containing that content, at property "link". | |
29 | 29 … | - Property "parents" is an array of links to the latest previous message(s) of the same type for the same page containing previous revisions to the page. Any revision parent id referenced from the current message should be found in the current message or a message referenced in this parents array. | |
30 … | +- Property "userId" is added to each revision object. It is computed the same as `pageId` but for the User page of the revision author. | ||
30 | 31 … | ||
31 | 32 … | Example: | |
32 | 33 … | ||
33 | 34 … | ``` | |
@@ -45,8 +46,9 @@ | |||
45 | 46 … | { | |
46 | 47 … | "revid": 999999999, | |
47 | 48 … | "parentid": 999999998, | |
48 | 49 … | "user": "Username", | |
50 … | + "userId": "&...sha256", | ||
49 | 51 … | "timestamp": "2019-11-22T00:00:00Z", | |
50 | 52 … | "roles": [ | |
51 | 53 … | "main" | |
52 | 54 … | ], |
bin.js | ||
---|---|---|
@@ -194,10 +194,12 @@ | ||
194 | 194 … | }) |
195 | 195 … | if (!--waiting) next() |
196 | 196 … | }) |
197 | 197 … | }(api)) |
198 … | + | |
198 | 199 … | function next() { |
199 | 200 … | console.log('Getting revisions...') |
201 … | + var userHashes = {} | |
200 | 202 … | pull( |
201 | 203 … | pull.values(pagesInfo), |
202 | 204 … | pull.asyncMap(function (pageInfo, cb) { |
203 | 205 … | // Calculate blob id for page URL + title, for linking |
@@ -290,8 +292,23 @@ | ||
290 | 292 … | }) |
291 | 293 … | }, |
292 | 294 … | pull.flatten(), |
293 | 295 … | pull.asyncMap(function (rev, cb) { |
296 … | + // Calculate blob id for user page URL + title, for linking | |
297 … | + var hash = userHashes[rev.user] | |
298 … | + if (hash) { | |
299 … | + rev.userId = hash | |
300 … | + return cb(null, rev) | |
301 … | + } | |
302 … | + pull( | |
303 … | + pull.once(pageInfo.site + '\tUser:' + rev.user), | |
304 … | + sbot.blobs.add(function (err, hash) { | |
305 … | + rev.userId = userHashes[rev.user] = hash | |
306 … | + cb(null, rev) | |
307 … | + }) | |
308 … | + ) | |
309 … | + }), | |
310 … | + pull.asyncMap(function (rev, cb) { | |
294 | 311 … | var waiting = 0 |
295 | 312 … | for (var slot in rev.slots) (function (slot) { |
296 | 313 … | waiting++ |
297 | 314 … | var slotInfo = rev.slots[slot] |
Built with git-ssb-web