LearnNewsExamplesServices
Frontmatter
id9037
titleRefactor: Dynamic Year Fields in Contributor Model
stateClosed
labels
airefactoring
assigneestobiu
createdAtFeb 7, 2026, 8:58 PM
updatedAtFeb 7, 2026, 9:03 PM
githubUrlhttps://github.com/neomjs/neo/issues/9037
authortobiu
commentsCount1
parentIssue8930
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtFeb 7, 2026, 9:03 PM

Refactor: Dynamic Year Fields in Contributor Model

Closed v12.0.0 airefactoring
tobiu
tobiu commented on Feb 7, 2026, 8:58 PM

Refactor apps/devrank/model/Contributor.mjs to dynamically generate year fields (current year down to 2010) instead of using a hardcoded list.

This approach:

  1. Ensures the model automatically includes the current year (e.g., 2026) without manual updates.
  2. Reduces boilerplate code.
  3. Mirrors the dynamic column generation logic in GridContainer.mjs.

Implementation Details:

  • Remove the hardcoded year fields from static config.fields.
  • Implement a dynamic generation logic (likely in onConstructed or a dedicated method called during class setup/init, though Neo.data.Model fields are usually static. For Models, we might need to stick to static definition or use a static block / IIFE to generate the array before assignment if we want it to be truly dynamic at load time).
  • Actually, Neo.data.Model processes fields in processFields. We can assign the fields array dynamically in the class definition itself using standard JS execution.

Example:

const fields = [...staticFields];
const currentYear = new Date().getFullYear();
for (let i = currentYear; i >= 2010; i--) {
    fields.push({name: `y${i}`, mapping: `years.${i}`, type: 'Integer'});
}
// assign fields to config
tobiu added the ai label on Feb 7, 2026, 8:58 PM
tobiu added the refactoring label on Feb 7, 2026, 8:58 PM
tobiu added parent issue #8930 on Feb 7, 2026, 8:58 PM
tobiu referenced in commit f8a975d - "refactor: Dynamic year fields in Contributor model (#9037)" on Feb 7, 2026, 9:02 PM
tobiu
tobiu Feb 7, 2026, 9:02 PM

Input from Gemini 3 Pro:

✦ Refactored Contributor model to generate year fields dynamically.

  • Removed hardcoded year fields from static config.fields.
  • Added addYearFields() method called in construct() to generate fields from the current year down to 2010.
  • Added proper JSDoc comments.

Changes pushed to dev.

tobiu assigned to @tobiu on Feb 7, 2026, 9:02 PM
tobiu closed this issue on Feb 7, 2026, 9:03 PM