Ppchelko has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/342154 )
Change subject: Provide debug endpoint
......................................................................
Provide debug endpoint
This provides two debugging URLs that are available for internal
usage. One generates a list of all ids/titles in current memory
allowing you to work out the id of a specific page.
You can then provide an id has a second parameter to see the internal
data stored for that page. This will allow you to identify if things
like reverts are being captured correctly.
Change-Id: I7d48ef28db7dd2ff3201e5684623a9dc4cfd2924
---
M lib/EventProcessor.js
M routes/trending-v1.js
2 files changed, 39 insertions(+), 0 deletions(-)
Approvals:
Ppchelko: Looks good to me, approved
jenkins-bot: Verified
diff --git a/lib/EventProcessor.js b/lib/EventProcessor.js
index 275e2bb..4fe15f4 100644
--- a/lib/EventProcessor.js
+++ b/lib/EventProcessor.js
@@ -60,6 +60,17 @@
}
/**
+ * Remove page with id from the store
+ *
+ * @ignore
+ * @param {Number} id of page
+ * @param {Object} page
+ */
+ getPage(id) {
+ return this.pages.get(id);
+ }
+
+ /**
* Process data structure representing edit
*
* @param {Object} edit
diff --git a/routes/trending-v1.js b/routes/trending-v1.js
index 2d5293d..1acfe36 100644
--- a/routes/trending-v1.js
+++ b/routes/trending-v1.js
@@ -42,6 +42,34 @@
}
/**
+ * GET /feed/debug-trending-edits
+ * Debugging tools for private usage that expose the contents of the processor
+ */
+router.get('/debug-trending-edits/:id?', function(req, res) {
+ const processor = app.processor;
+ if (req.params.id) {
+ const page = processor.getPage(parseInt(req.params.id, 10));
+ if (page) {
+ res.status(200).type('application/json').end(
+ JSON.stringify(scorePages(new Date(), [page]))
+ );
+ } else {
+ res.status(404).type('application/json').end('Unknown page title');
+ }
+ } else {
+ const pages = processor.getPages();
+ res.status(200).type('application/json').end(
+ JSON.stringify({
+ size: pages.length,
+ titles: pages.map((page) => {
+ return { id: page.id, title: page.title };
+ })
+ })
+ );
+ }
+});
+
+/**
* GET /feed/trending-edits
* Gets the body of a given page.
*/
--
To view, visit https://gerrit.wikimedia.org/r/342154
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7d48ef28db7dd2ff3201e5684623a9dc4cfd2924
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/services/trending-edits
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: BearND <[email protected]>
Gerrit-Reviewer: Ppchelko <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits