You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kibble.apache.org by hu...@apache.org on 2018/01/17 18:37:41 UTC

[kibble] 05/06: fix up comstat widget, add it to the widget yaml list

This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kibble.git

commit 39a75dcac37410d48e1bc7e8619a7d058658c3be
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Wed Jan 17 19:37:20 2018 +0100

    fix up comstat widget, add it to the widget yaml list
---
 api/yaml/widgets.yaml              |  31 +++++++
 ui/js/coffee/widget_comstat.coffee | 167 ++++++++++++++++++++-----------------
 2 files changed, 120 insertions(+), 78 deletions(-)

diff --git a/api/yaml/widgets.yaml b/api/yaml/widgets.yaml
index a1572ce..dedbbab 100644
--- a/api/yaml/widgets.yaml
+++ b/api/yaml/widgets.yaml
@@ -680,3 +680,34 @@ widgets:
                         source: "mail/mood-timeseries"
                         name:   "Mood over time"
                         blocks: 12
+
+## NEWTIMERS (COMSTAT)
+    comstat:
+        title: "Community Growth"
+        rows:
+            -
+                name: "Date picker row"
+                children:
+                    -
+                        type:   "datepicker"
+                        blocks: 4
+                        name:   "Date picker"
+                    -
+                        type:   "viewpicker"
+                        blocks: 4
+                        source: "views"
+                        name:   "Quick filter"
+                    -
+                        type:   sourcepicker
+                        blocks: 4
+                        source: "sources"
+                        name:   "Source picker"
+            -
+                name: "Community Growth"
+                children:
+                    -
+                        type:   "comstat"
+                        source: "bio/newtimers"
+                        name:   "New contributors"
+                        blocks: 12
+                    
\ No newline at end of file
diff --git a/ui/js/coffee/widget_comstat.coffee b/ui/js/coffee/widget_comstat.coffee
index 88013b1..2a6dfca 100644
--- a/ui/js/coffee/widget_comstat.coffee
+++ b/ui/js/coffee/widget_comstat.coffee
@@ -23,9 +23,8 @@ comstat = (json, state) ->
         if json.stats.code.seen > 0
             row = new Row()
             js = { alphaSort: true, counts: {
-                "Regulars": json.stats.code.seen - json.stats.code.newcomers - json.stats.code.returning,
-                "Newcomers": json.stats.code.newcomers,
-                "Returning": json.stats.code.returning
+                "Regulars": json.stats.code.seen - json.stats.code.newcomers.length,
+                "Newcomers": json.stats.code.newcomers.length,
                 }
             }
             widget = new Widget(4, {name: "Code contributors this period", representation: 'comstat'})
@@ -35,21 +34,26 @@ comstat = (json, state) ->
             row.inject(widget)
             donut(js, { widget: widget})
             nl = 0
-            if json.stats.code.newtbl.length and json.stats.code.newtbl.length >= 0
-                nl = json.stats.code.newtbl.length
-            stbl = new Widget(4, { name: "New code contributors (#{nl})" })
+            if json.stats.code.newcomers.length and json.stats.code.newcomers.length >= 0
+                nl = json.stats.code.newcomers.length
+            stbl = new Widget(6, { name: "New code contributors (#{nl})" })
             
             tbl = mk('table', {class: "table table-striped"})
             tr = mk('tr', {}, [
                 mk('th', {}, "Avatar"),
                 mk('th', {}, "Name",)
                 mk('th', {}, "Address"),
+                mk('th', {}, "First commit"),
                 ])
             app(tbl, tr)
             tb = new HTML('tbody')
-            for person, i in json.stats.code.newtbl
+            for person, i in json.stats.code.newcomers
+                oemail = person
+                hash = json.bios[person].code[1].id.split('/')[1]
+                repo = json.bios[person].code[1].sourceURL
+                person = json.bios[person].bio
                 if i > 6
-                    m = json.stats.code.newtbl.length - 7
+                    m = json.stats.code.newcomers.length - 7
                     tr = mk('tr', {scope: 'row'}, [
                         mk('td', {colspan: "3"}, "+#{m} more...")
                         ])
@@ -57,8 +61,9 @@ comstat = (json, state) ->
                     break
                 tr = mk('tr', {scope: 'row'}, [
                     mk('td', {}, new HTML('img', {style: { width: '32px', height: '32px'}, class: "img-circle img-responsive", src:"https://secure.gravatar.com/avatar/#{person.md5}.png?d=identicon"})),
-                    mk('td', {}, mk('a', { href: "?page=people&email=#{person.address}"}, person.name)),
-                    mk('td', {}, person.address),
+                    mk('td', {}, mk('a', { href: "?page=people&email=#{oemail}"}, person.name)),
+                    mk('td', {}, oemail),
+                    mk('td', {}, "#{repo} / #{hash}"),
                     ])
                 tb.inject(tr)
             app(tbl, tb)
@@ -79,9 +84,8 @@ comstat = (json, state) ->
         if json.stats.issues.seen > 0
             row = new Row()
             js = { alphaSort: true, counts: {
-                "Regulars": json.stats.issues.seen - json.stats.issues.newcomers - json.stats.issues.returning,
-                "Newcomers": json.stats.issues.newcomers,
-                "Returning": json.stats.issues.returning
+                "Regulars": json.stats.issues.seen - json.stats.issues.newcomers.length,
+                "Newcomers": json.stats.issues.newcomers.length
                 }
             }
             widget = new Widget(4, {name: "Issue contributors this period", representation: 'comstat'})
@@ -91,30 +95,37 @@ comstat = (json, state) ->
             row.inject(widget)
             donut(js, { widget: widget})
             nl = 0
-            if json.stats.issues.newtbl.length and json.stats.issues.newtbl.length >= 0
-                nl = json.stats.issues.newtbl.length
-            stbl = new Widget(4, { name: "New issue contributors (#{nl})" })
+            if json.stats.issues.newcomers.length and json.stats.issues.newcomers.length >= 0
+                nl = json.stats.issues.newcomers.length
+            stbl = new Widget(6, { name: "New issue contributors (#{nl})" })
             
             tbl = mk('table', {class: "table table-striped"})
             tr = mk('tr', {}, [
                 mk('th', {}, "Avatar"),
                 mk('th', {}, "Name",)
                 mk('th', {}, "Address"),
+                mk('th', {}, "First issue"),
                 ])
             app(tbl, tr)
             tb = new HTML('tbody')
-            for person, i in json.stats.issues.newtbl
+            for person, i in json.stats.issues.newcomers
+                oemail = person
+                url = json.bios[person].issue[1].sourceURL
+                key = json.bios[person].issue[1].key || url
+                person = json.bios[person].bio
                 if i > 6
-                    m = json.stats.issues.newtbl.length - 7
+                    m = json.stats.issues.newcomers.length - 7
                     tr = mk('tr', {scope: 'row'}, [
                         mk('td', {colspan: "3"}, "+#{m} more...")
                         ])
                     tb.inject(tr)
                     break
+                
                 tr = mk('tr', {scope: 'row'}, [
                     mk('td', {}, new HTML('img', {style: { width: '32px', height: '32px'}, class: "img-circle img-responsive", src:"https://secure.gravatar.com/avatar/#{person.md5}.png?d=identicon"})),
-                    mk('td', {}, mk('a', { href: "?page=people&email=#{person.address}"}, person.name)),
-                    mk('td', {}, person.address),
+                    mk('td', {}, mk('a', { href: "?page=people&email=#{oemail}"}, person.name)),
+                    mk('td', {}, oemail),
+                    mk('td', {}, mk('a', { href: url||"#"}, txt(key))),
                     ])
                 tb.inject(tr)
             app(tbl, tb)
@@ -122,7 +133,7 @@ comstat = (json, state) ->
             row.inject(stbl)
             
             if json.stats.issues.timeseries and json.stats.issues.timeseries.length > 0
-                widget = new Widget(4, {name: "New issue contributors over time:", representation: 'bars'})
+                widget = new Widget(6, {name: "New issue contributors over time:", representation: 'bars'})
                 widget.parent = state.widget
                 row.inject(widget)
                 js = {widgetType: { chartType: 'bar'}, timeseries: json.stats.issues.timeseries}
@@ -132,66 +143,66 @@ comstat = (json, state) ->
             
             
             state.widget.inject(row.div)
-            
-        if json.stats.converts.issue_to_code.length and json.stats.converts.issue_to_code.length > 0
-            row = new Row()
-            
-            stbl = new Widget(6, { name: "Previous issue contributors who are now contributing code:" })
-            
-            tbl = mk('table', {class: "table table-striped"})
-            tr = mk('tr', {}, [
-                mk('th', {}, "Avatar"),
-                mk('th', {}, "Name",)
-                mk('th', {}, "Address"),
-                mk('th', {}, "Days from first issue to first code contribution:"),
-                ])
-            app(tbl, tr)
-            tb = new HTML('tbody')
-            for person, i in json.stats.converts.issue_to_code
-                if i > 20
-                    break
-                tr = mk('tr', {scope: 'row'}, [
-                    mk('td', {}, new HTML('img', {style: { width: '32px', height: '32px'}, class: "img-circle img-responsive", src:"https://secure.gravatar.com/avatar/#{person.md5}.png?d=identicon"})),
-                    mk('td', {}, mk('a', { href: "?page=people&email=#{person.address}"}, person.name)),
-                    mk('td', {}, person.address),
-                    mk('td', {style: { textAlign: 'right'}}, (Math.floor(person.tdiff / (86400))).pretty()),
+        if json.stats.converts
+            if json.stats.converts.issue_to_code.length and json.stats.converts.issue_to_code.length > 0
+                row = new Row()
+                
+                stbl = new Widget(6, { name: "Previous issue contributors who are now contributing code:" })
+                
+                tbl = mk('table', {class: "table table-striped"})
+                tr = mk('tr', {}, [
+                    mk('th', {}, "Avatar"),
+                    mk('th', {}, "Name",)
+                    mk('th', {}, "Address"),
+                    mk('th', {}, "Days from first issue to first code contribution:"),
                     ])
-                tb.inject(tr)
-            app(tbl, tb)
-            stbl.inject(tbl)
-            row.inject(stbl)
-            
-            state.widget.inject(row.div)
-        
-        if json.stats.converts.email_to_code.length and json.stats.converts.email_to_code.length > 0
-            row = new Row()
-            
-            stbl = new Widget(6, { name: "Previous email authors who are now contributing code:" })
+                app(tbl, tr)
+                tb = new HTML('tbody')
+                for person, i in json.stats.converts.issue_to_code
+                    if i > 20
+                        break
+                    tr = mk('tr', {scope: 'row'}, [
+                        mk('td', {}, new HTML('img', {style: { width: '32px', height: '32px'}, class: "img-circle img-responsive", src:"https://secure.gravatar.com/avatar/#{person.md5}.png?d=identicon"})),
+                        mk('td', {}, mk('a', { href: "?page=people&email=#{person.address}"}, person.name)),
+                        mk('td', {}, person.address),
+                        mk('td', {style: { textAlign: 'right'}}, (Math.floor(person.tdiff / (86400))).pretty()),
+                        ])
+                    tb.inject(tr)
+                app(tbl, tb)
+                stbl.inject(tbl)
+                row.inject(stbl)
+                
+                state.widget.inject(row.div)
             
-            tbl = mk('table', {class: "table table-striped"})
-            tr = mk('tr', {}, [
-                mk('th', {}, "Avatar"),
-                mk('th', {}, "Name",)
-                mk('th', {}, "Address"),
-                mk('th', {}, "Days from first email to first code contribution:"),
-                ])
-            app(tbl, tr)
-            tb = new HTML('tbody')
-            for person, i in json.stats.converts.email_to_code
-                if i > 20
-                    break
-                tr = mk('tr', {scope: 'row'}, [
-                    mk('td', {}, new HTML('img', {style: { width: '32px', height: '32px'}, class: "img-circle img-responsive", src:"https://secure.gravatar.com/avatar/#{person.md5}.png?d=identicon"})),
-                    mk('td', {}, mk('a', { href: "?page=people&email=#{person.address}"}, person.name)),
-                    mk('td', {}, person.address),
-                    mk('td', {style: { textAlign: 'right'}}, (Math.floor(person.tdiff / (86400))).pretty()),
+            if json.stats.converts.email_to_code.length and json.stats.converts.email_to_code.length > 0
+                row = new Row()
+                
+                stbl = new Widget(6, { name: "Previous email authors who are now contributing code:" })
+                
+                tbl = mk('table', {class: "table table-striped"})
+                tr = mk('tr', {}, [
+                    mk('th', {}, "Avatar"),
+                    mk('th', {}, "Name",)
+                    mk('th', {}, "Address"),
+                    mk('th', {}, "Days from first email to first code contribution:"),
                     ])
-                tb.inject(tr)
-            app(tbl, tb)
-            stbl.inject(tbl)
-            row.inject(stbl)
-            
-            state.widget.inject(row.div)
+                app(tbl, tr)
+                tb = new HTML('tbody')
+                for person, i in json.stats.converts.email_to_code
+                    if i > 20
+                        break
+                    tr = mk('tr', {scope: 'row'}, [
+                        mk('td', {}, new HTML('img', {style: { width: '32px', height: '32px'}, class: "img-circle img-responsive", src:"https://secure.gravatar.com/avatar/#{person.md5}.png?d=identicon"})),
+                        mk('td', {}, mk('a', { href: "?page=people&email=#{person.address}"}, person.name)),
+                        mk('td', {}, person.address),
+                        mk('td', {style: { textAlign: 'right'}}, (Math.floor(person.tdiff / (86400))).pretty()),
+                        ])
+                    tb.inject(tr)
+                app(tbl, tb)
+                stbl.inject(tbl)
+                row.inject(stbl)
+                
+                state.widget.inject(row.div)
     else
         notice = new HTML('h2', {}, "Community growth stats only works with user-defined views!")
         p = new HTML('p', {}, "To see community growth stats, please create a view of the code, email, bugs you wish to view stats for, or select an existng view in the list above")

-- 
To stop receiving notification emails like this one, please contact
"commits@kibble.apache.org" <co...@kibble.apache.org>.