From commits-return-9988-apmail-community-commits-archive=community.apache.org@community.apache.org Sat Aug 3 04:53:39 2019 Return-Path: X-Original-To: apmail-community-commits-archive@minotaur.apache.org Delivered-To: apmail-community-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by minotaur.apache.org (Postfix) with SMTP id E729F1971F for ; Sat, 3 Aug 2019 04:53:38 +0000 (UTC) Received: (qmail 93259 invoked by uid 500); 3 Aug 2019 04:53:38 -0000 Delivered-To: apmail-community-commits-archive@community.apache.org Received: (qmail 93228 invoked by uid 500); 3 Aug 2019 04:53:38 -0000 Mailing-List: contact commits-help@community.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@community.apache.org Delivered-To: mailing list commits@community.apache.org Received: (qmail 93218 invoked by uid 99); 3 Aug 2019 04:53:38 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 03 Aug 2019 04:53:38 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id E273F3A0573 for ; Sat, 3 Aug 2019 04:53:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1864304 - in /comdev/reporter.apache.org/trunk/site/wizard/js: source/generators.js wizard.js Date: Sat, 03 Aug 2019 04:53:36 -0000 To: commits@community.apache.org From: humbedooh@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20190803045336.E273F3A0573@svn01-us-west.apache.org> Author: humbedooh Date: Sat Aug 3 04:53:35 2019 New Revision: 1864304 URL: http://svn.apache.org/viewvc?rev=1864304&view=rev Log: refactor ratio math Modified: comdev/reporter.apache.org/trunk/site/wizard/js/source/generators.js comdev/reporter.apache.org/trunk/site/wizard/js/wizard.js Modified: comdev/reporter.apache.org/trunk/site/wizard/js/source/generators.js URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/wizard/js/source/generators.js?rev=1864304&r1=1864303&r2=1864304&view=diff ============================================================================== --- comdev/reporter.apache.org/trunk/site/wizard/js/source/generators.js (original) +++ comdev/reporter.apache.org/trunk/site/wizard/js/source/generators.js Sat Aug 3 04:53:35 2019 @@ -1,6 +1,3 @@ -// Least common multiple -let lcm = (x, y) => (!x || !y) ? 0 : Math.abs((x * y) / gcd(x, y)); - // Greatest common divisor let gcd = (x,y) => { x = Math.abs(x); @@ -26,26 +23,35 @@ function generate_pmc_roster(pdata) { let y1 = no_com; let y2 = no_pmc; - while (y1 > 20) { - y1 = Math.round(y1/2) - y2 = Math.round(y2/2); - } - l = lcm(y1, y2); - x1 = l/y2; - x2 = l/y1; - while (x1 >= 10) { - x1 /= 1.25; - x2 /= 1.25; - } - x1 = Math.round(x1) - x2 = Math.round(x2) + let cpr = ""; - let k = gcd(x1, x2); - x1 /= k; - x2 /= k; + // See if we can get a clean ratio + let k = gcd(y1, y2); + y1 /= k; + y2 /= k; + if (y1 < 10 && y2 < 10) cpr = "%u:%u".format(y1,y2); + + // Nope, let's rough it up a bit. + else { + // While >= 10 committers, halven both committers and pmc + // to get a simpler number to "mathify". + while (y1 >= 10) { + y1 = Math.round(y1/2) + y2 = Math.round(y2/2); + } + // round up/down + y1 = Math.round(y1); + y2 = Math.round(y2); + + // find greatest common divisor and make the final fraction + let k = gcd(y1, y2); + y1 /= k; + y2 /= k; + cpr = "roughly %u:%u".format(y1,y2); + } - txt += "There are currently %u committers and %u PMC members in this project.\nThe Committer-to-PMC ratio is %u:%u.\n\n".format(no_com, no_pmc, x1, x2); + txt += "There are currently %u committers and %u PMC members in this project.\nThe Committer-to-PMC ratio is %s.\n\n".format(no_com, no_pmc, cpr); Modified: comdev/reporter.apache.org/trunk/site/wizard/js/wizard.js URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/wizard/js/wizard.js?rev=1864304&r1=1864303&r2=1864304&view=diff ============================================================================== --- comdev/reporter.apache.org/trunk/site/wizard/js/wizard.js (original) +++ comdev/reporter.apache.org/trunk/site/wizard/js/wizard.js Sat Aug 3 04:53:35 2019 @@ -1167,9 +1167,6 @@ function report_published(state, json) { Fetched from source/generators.js ******************************************/ -// Least common multiple -let lcm = (x, y) => (!x || !y) ? 0 : Math.abs((x * y) / gcd(x, y)); - // Greatest common divisor let gcd = (x,y) => { x = Math.abs(x); @@ -1195,26 +1192,35 @@ function generate_pmc_roster(pdata) { let y1 = no_com; let y2 = no_pmc; - while (y1 > 20) { - y1 = Math.round(y1/2) - y2 = Math.round(y2/2); - } - l = lcm(y1, y2); - x1 = l/y2; - x2 = l/y1; - while (x1 >= 10) { - x1 /= 1.25; - x2 /= 1.25; - } - x1 = Math.round(x1) - x2 = Math.round(x2) + let cpr = ""; - let k = gcd(x1, x2); - x1 /= k; - x2 /= k; + // See if we can get a clean ratio + let k = gcd(y1, y2); + y1 /= k; + y2 /= k; + if (y1 < 10 && y2 < 10) cpr = "%u:%u".format(y1,y2); + + // Nope, let's rough it up a bit. + else { + // While >= 10 committers, halven both committers and pmc + // to get a simpler number to "mathify". + while (y1 >= 10) { + y1 = Math.round(y1/2) + y2 = Math.round(y2/2); + } + // round up/down + y1 = Math.round(y1); + y2 = Math.round(y2); + + // find greatest common divisor and make the final fraction + let k = gcd(y1, y2); + y1 /= k; + y2 /= k; + cpr = "roughly %u:%u".format(y1,y2); + } - txt += "There are currently %u committers and %u PMC members in this project.\nThe Committer-to-PMC ratio is %u:%u.\n\n".format(no_com, no_pmc, x1, x2); + txt += "There are currently %u committers and %u PMC members in this project.\nThe Committer-to-PMC ratio is %s.\n\n".format(no_com, no_pmc, cpr);