couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [1/4] admin commit: updated refs/heads/master to db84dab
Date Wed, 18 Feb 2015 10:17:01 GMT
Repository: couchdb-admin
Updated Branches:
  refs/heads/master 59aab1212 -> db84dab07


Automate mailinglist message count collection

It seems that there is a lot of manual work needed to generate
the board reports. This is an attempt to start automating the
recurring tasks.

Happy reporting! :)


Project: http://git-wip-us.apache.org/repos/asf/couchdb-admin/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-admin/commit/e5a2458e
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-admin/tree/e5a2458e
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-admin/diff/e5a2458e

Branch: refs/heads/master
Commit: e5a2458e9619d46d495a4a4ff02f29a08691a50e
Parents: 59aab12
Author: Robert Kowalski <rok@kowalski.gd>
Authored: Sat Nov 15 21:12:15 2014 +0100
Committer: Robert Kowalski <rok@kowalski.gd>
Committed: Sat Nov 15 21:12:15 2014 +0100

----------------------------------------------------------------------
 .gitignore                   |   1 +
 board-report/README.md       |  10 ++++
 board-report/generate-report | 112 ++++++++++++++++++++++++++++++++++++++
 board-report/lib/index.js    |  60 ++++++++++++++++++++
 board-report/package.json    |  17 ++++++
 5 files changed, 200 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-admin/blob/e5a2458e/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3c3629e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+node_modules

http://git-wip-us.apache.org/repos/asf/couchdb-admin/blob/e5a2458e/board-report/README.md
----------------------------------------------------------------------
diff --git a/board-report/README.md b/board-report/README.md
new file mode 100644
index 0000000..821294a
--- /dev/null
+++ b/board-report/README.md
@@ -0,0 +1,10 @@
+# generate-report
+
+## Usage
+
+```shell
+generate-report <daterange> | --help
+```
+
+If you are reporting for February 2014, for instance,
+set the date range to: `201311-201402`.

http://git-wip-us.apache.org/repos/asf/couchdb-admin/blob/e5a2458e/board-report/generate-report
----------------------------------------------------------------------
diff --git a/board-report/generate-report b/board-report/generate-report
new file mode 100755
index 0000000..230a859
--- /dev/null
+++ b/board-report/generate-report
@@ -0,0 +1,112 @@
+#!/usr/bin/env node
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+const crawler = require('./lib/index.js');
+
+const arg = process.argv[2];
+
+if (arg === '-h' || arg === '--help') {
+  return printUsage();
+}
+
+if (!validArg(arg)) {
+  console.log('Error: format is YYYYMM-YYYYMM - see ' +
+    "'generate-report --help'");
+  return;
+}
+
+const template = '{{count}} {{messages}} since {{month}} ' +
+  '(DIFF change)';
+
+crawler(arg, function (err, data) {
+  if (err) {
+    logLine('Error:');
+    console.log(err);
+    return;
+  }
+
+  logLine('Your message counts:');
+  data.forEach(function (el) {
+    const month = getStartMonthAsWord(arg),
+          messageCount = +el[1].replace(',', ''),
+          message = messageCount > 1 ? 'messages' : 'message',
+          wikitext = template
+            .replace('{{count}}', el[1])
+            .replace('{{month}}', month)
+            .replace('{{messages}}', message);
+
+    console.log(el[0] + ':');
+    logLine(wikitext);
+  });
+  console.log('Happy reporting! :)');
+});
+
+function logLine (line) {
+  console.log(line + '\n');
+}
+
+function getStartMonthAsWord (date) {
+  const i = parseInt(date.substr(4, 2), 10);
+  return getMonthAsWord(i);
+}
+
+function getMonthAsWord (i) {
+  return [
+    'January',
+    'February',
+    'March',
+    'April',
+    'May',
+    'June',
+    'July',
+    'August',
+    'September',
+    'October',
+    'November',
+    'December'
+  ][i - 1];
+}
+
+function validArg (arg) {
+  if (!arg) {
+    return false;
+  }
+
+  const dates = arg.split('-');
+
+  if (dates.length !== 2) {
+    return false;
+  }
+
+  if (dates[0].length !== 6 || dates[1].length !== 6) {
+    return false;
+  }
+
+  if (Number.isNaN(+dates[0]) || Number.isNaN(+dates[1])) {
+    return false;
+  }
+
+  return true;
+}
+
+function printUsage () {
+  logLine('usage: generate-report <daterange> | --help');
+  console.log('If you are reporting for February 2014, for instance,');
+  logLine('set the date range to: 201311-201402');
+  console.log('guide:');
+  console.log('https://cwiki.apache.org/confluence/display' +
+    '/COUCHDB/Guide');
+  console.log('template:');
+  console.log('https://cwiki.apache.org/confluence/display' +
+    '/COUCHDB/Template');
+}

http://git-wip-us.apache.org/repos/asf/couchdb-admin/blob/e5a2458e/board-report/lib/index.js
----------------------------------------------------------------------
diff --git a/board-report/lib/index.js b/board-report/lib/index.js
new file mode 100644
index 0000000..db2a324
--- /dev/null
+++ b/board-report/lib/index.js
@@ -0,0 +1,60 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+const async = require('async'),
+      request = require('request'),
+      cheerio = require('cheerio');
+
+const urlTemplate = 'http://markmail.org/search/?q=list%3A' +
+  'org.apache.{{listname}}%20date%3A{{date}}';
+
+const lists = [
+  'couchdb-announce',
+  'couchdb-user',
+  'couchdb-erlang',
+  'couchdb-dev',
+  'couchdb-commits',
+  'couchdb-l10n',
+  'couchdb-replication',
+  'couchdb-marketing'
+];
+
+function getMessageCounts (date, cb) {
+  const listUrls = lists.map(function (list) {
+    return urlTemplate
+      .replace('{{date}}', date)
+      .replace('{{listname}}', list);
+  });
+
+  async.map(listUrls, request, function (err, results) {
+    if (err) {
+      return cb(err);
+    }
+
+    const bodies = results.reduce(function (acc, cur) {
+      acc.push(cur.request.req.res.body);
+      return acc;
+    }, []);
+
+    const res = bodies.map(function (markup) {
+      const $ = cheerio.load(markup),
+            count = $('#lists .count').text(),
+            list = $('#lists a').text().replace('org.apache.couchdb.', '');
+
+      return [list, count];
+    });
+
+    return cb(null, res);
+  });
+}
+
+module.exports = getMessageCounts;

http://git-wip-us.apache.org/repos/asf/couchdb-admin/blob/e5a2458e/board-report/package.json
----------------------------------------------------------------------
diff --git a/board-report/package.json b/board-report/package.json
new file mode 100644
index 0000000..6fb1742
--- /dev/null
+++ b/board-report/package.json
@@ -0,0 +1,17 @@
+{
+  "name": "board-report",
+  "version": "1.0.0",
+  "private": true,
+  "description": "I'm helping to prepare board reports",
+  "main": "lib/index.js",
+  "scripts": {
+    "test": "echo \"Error: no test specified\" && exit 1"
+  },
+  "author": "Robert Kowalski <rok@kowalski.gd>",
+  "license": "Apache License, Version 2.0",
+  "dependencies": {
+    "async": "0.9.0",
+    "cheerio": "0.18.0",
+    "request": "2.48.0"
+  }
+}


Mime
View raw message