Skip to content

Commit 97f958b

Browse files
committed
feat(devindex): Add Commit Ratio column and automation filter (#9177)
1 parent 8aecb0e commit 97f958b

5 files changed

Lines changed: 45 additions & 0 deletions

File tree

apps/devindex/model/Contributor.mjs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,28 @@ class Contributor extends Model {
7777
calculate: data => {
7878
return (data.commitsArray || data.cy)?.reduce((a, b) => a + b, 0) || 0
7979
}
80+
},
81+
{
82+
name: 'commitRatio',
83+
type: 'Float',
84+
/**
85+
* Calculates the ratio of commits to total contributions (0-100).
86+
* @param {Object|Neo.data.Record} data
87+
* @returns {Number}
88+
*/
89+
calculate: data => {
90+
// Optimization: Use totalCommits if already calculated (Record context)
91+
// Fallback: Calculate from raw array (Raw/Store context)
92+
let commits = data.totalCommits;
93+
94+
if (commits === undefined) {
95+
commits = (data.commitsArray || data.cy)?.reduce((a, b) => a + b, 0) || 0
96+
}
97+
98+
const total = data.totalContributions || data.tc || 0;
99+
100+
return total === 0 ? 0 : (commits / total) * 100
101+
}
80102
}
81103
]
82104
}

apps/devindex/store/Contributors.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class Contributors extends Store {
3434
*/
3535
filters: [
3636
{property: 'bio', operator: 'like', value: null},
37+
{property: 'commitRatio', operator: '<=', value: null},
3738
{property: 'countryCode', operator: '===', value: null},
3839
{property: 'isHireable', operator: '===', value: null},
3940
{property: 'login', operator: 'like', value: null},

apps/devindex/view/home/ControlsContainer.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ class ControlsContainer extends Container {
102102
style : {marginTop: '1em'},
103103
valueLabel : 'Hireable Only',
104104
width : 200
105+
}, {
106+
module : CheckBox,
107+
checked : false,
108+
hideLabel : true,
109+
listeners : {change: 'onHideAutomationChange'},
110+
style : {marginTop: '1em'},
111+
valueLabel : 'Hide Commit Ratio > 90%',
112+
width : 200
105113
}]
106114
}, {
107115
module : Profile,

apps/devindex/view/home/GridContainer.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,13 @@ class GridContainer extends BaseGridContainer {
173173
cellAlign : 'right',
174174
defaultSortDirection: 'DESC',
175175
renderer : ({value}) => new Intl.NumberFormat().format(value)
176+
}, {
177+
dataField : 'commitRatio',
178+
text : 'Commits %',
179+
width : 110,
180+
cellAlign : 'right',
181+
defaultSortDirection: 'DESC',
182+
renderer : ({value}) => (value || 0).toFixed(2)
176183
}, {
177184
dataField: 'activity',
178185
text : `Activity (${activityDuration}y)`,

apps/devindex/view/home/MainContainerController.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ class MainContainerController extends Controller {
121121
}
122122
}
123123

124+
/**
125+
* @param {Object} data
126+
*/
127+
onHideAutomationChange(data) {
128+
this.getReference('grid').store.getFilter('commitRatio').value = data.value ? 90 : null
129+
}
130+
124131
/**
125132
* @param {Object} data
126133
*/

0 commit comments

Comments
 (0)