File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,8 +49,25 @@ class Contributor extends Model {
4949 {
5050 name : 'total_commits' ,
5151 type : 'Integer' ,
52+ /**
53+ * Calculates the total commits from the yearly breakdown.
54+ *
55+ * **Turbo Mode / Soft Hydration Compatibility:**
56+ * In "Turbo Mode" (autoInitRecords: false), the Store sorts raw JSON objects, not Record instances.
57+ * The `Neo.data.Store#doSort` "Soft Hydration" logic resolves this field (`total_commits`)
58+ * by calling this `calculate` function on the raw object.
59+ *
60+ * - **Record Context:** `data` is a Record. `data.commits_array` exists (via getter/mapping).
61+ * - **Raw Context:** `data` is a POJO. `data.commits_array` is undefined. `data.cy` exists.
62+ *
63+ * To support both contexts without forcing full record instantiation (performance killer),
64+ * we must check for both the canonical name AND the raw data key.
65+ *
66+ * @param {Object|Neo.data.Record } data
67+ * @returns {Number }
68+ */
5269 calculate : data => {
53- return data . commits_array ?. reduce ( ( a , b ) => a + b , 0 ) || 0 ;
70+ return ( data . commits_array || data . cy ) ?. reduce ( ( a , b ) => a + b , 0 ) || 0 ;
5471 }
5572 }
5673 ]
You can’t perform that action at this time.
0 commit comments