How restream/redmine_custom_reports works
Project type and purpose
• This is a Ruby on Rails plugin for Redmine (a project management web app).
• Its purpose is to allow users to define “Custom Reports” (with filters, grouping, and multiple data series) and render them as interactive charts.
File structure
• app/controllers: defines a CustomReportsController that handles HTTP requests for listing, creating, editing, deleting reports.
• app/models: two domain models—CustomReport and CustomReportSeries—plus a query extension.
• app/views: ERB templates that render HTML forms and chart containers.
• assets/javascripts & stylesheets: custom JS (custom_report_charts.js, custom_report_edit.js) plus D3/NVD3 libraries; CSS for charts.
• config/routes.rb: mounts plugin routes under the Redmine UI.
• db/migrate: migrations to create plugin-specific tables.
• lib/redmine_custom_reports: initialization code plus patches to Redmine’s Project and User models.
• init.rb: plugin registration entry point for Redmine.
README for additional insights
• Confirms use of d3.js and NVD3 for charting.
• Describes permission model (View vs Manage custom reports).
• Explains Redmine plugin installation and compatibility.
Main components and interactions
a. Components
– Redmine Core (Rails app, controllers, models for Issues, Projects, Users)
– Custom Reports Plugin module
• init.rb & lib/… (hook into Redmine startup; monkey-patch models)
• Plugin MVC: CustomReportsController, CustomReport and CustomReportSeries models, views
• Assets: JavaScript chart code + D3/NVD3 + CSS
• Database tables: custom_reports, custom_report_series
– Browser (end-user UI)
– Database (MySQL or PostgreSQL, shared with Redmine core)
– External Libraries: D3.js, NVD3
b. Interactions & Data Flow
1. User’s browser requests a plugin route (e.g., GET /projects/:id/custom_reports).
2. Rails router (config/routes.rb) dispatches to CustomReportsController.
3. Controller uses plugin models (and Redmine’s Issue/query logic via query_ext.rb) to assemble data.
4. Controller queries DB (custom_reports tables + Redmine’s issues tables).
5. Controller renders an ERB view, injecting chart container and data endpoints.
6. Browser loads assets (custom_report_charts.js, d3.v2.js, nv.d3.js).
7. JavaScript fetches JSON data (via endpoints) and renders charts client-side.
c. Architectural patterns & design principles
– Rails MVC inside a Redmine plugin (Engine-style)
– Monkey-patch extensions (ProjectPatch, UserPatch) to hook into Redmine core
– RESTful controller actions for CRUD operations
– Client-heavy chart rendering via D3/NVD3
d. Key technologies
– Ruby on Rails (plugin for Redmine 2.x/3.x)
– ERB templating
– JavaScript: D3.js, NVD3
– Database: MySQL/PostgreSQL
– Testing: Test::Unit functional tests