Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
0482baf
fix: ensure task status dropdown options are displayed in the correct…
DinuniWork Nov 17, 2026
0be6cf8
feat: add reporting schedules API endpoints
DinuniWork Nov 17, 2026
c617e91
feat: enhance email functionality and add analytics reporting jobs
DinuniWork Nov 17, 2026
f569d40
feat: add scheduling functionality for reports
DinuniWork Nov 17, 2026
421cf56
feat: enhance reporting components with scheduling capabilities
DinuniWork Nov 17, 2026
702440f
feat: enhance reporting analytics with new scheduling features
DinuniWork Nov 17, 2026
4981520
feat: update localization for scheduling features in reporting analytics
DinuniWork Nov 17, 2026
68c8f3c
feat: integrate SESv2 for enhanced email functionality
DinuniWork Nov 17, 2026
fe6c528
feat: enhance reporting analytics with chart integration in exports
DinuniWork Nov 17, 2026
f969321
feat: enhance ScheduleReportModal layout for improved user experience
DinuniWork Nov 17, 2026
773a350
refactor: streamline TimePicker component in ScheduleReportModal
DinuniWork Nov 17, 2026
a83ab78
refactor: improve ScheduledReportsHubPanel loading behavior
DinuniWork Nov 17, 2026
cbdf208
feat: add aria labels for row actions in reporting analytics
DinuniWork Nov 17, 2026
e93c16e
feat: enhance reporting analytics with multi-chart support in exports
DinuniWork Nov 17, 2026
6f9ba39
feat: enhance analytics reporting with improved database connection h…
DinuniWork Nov 18, 2026
3f42e01
feat: enhance project health reporting with date range filters
DinuniWork Nov 18, 2026
040a914
feat: add date range filters to planned vs actual tasks reporting
DinuniWork Nov 18, 2026
b561b64
feat: implement date range filtering in planned vs actual milestones …
DinuniWork Nov 18, 2026
95981a0
feat: add date range filtering to budget tracking analytics
DinuniWork Nov 18, 2026
a6d62b5
feat: enhance analytics schedules with new listing functionality
DinuniWork Nov 18, 2026
9d713a8
feat: add timezone support to analytics schedule exports and filters
DinuniWork Nov 18, 2026
a931862
feat: enhance PDF export with a fixed header table and improved layout
DinuniWork Nov 18, 2026
5ce688c
feat: enhance scheduled reports functionality with filter management
DinuniWork Nov 18, 2026
7a06ae2
feat: integrate chartsheet for native Excel chart support in exports
DinuniWork Nov 18, 2026
2309bdb
feat: enhance email reports with time range information
DinuniWork Nov 18, 2026
a6b1ced
feat: enhance project health analytics with explicit project tracking
DinuniWork Nov 18, 2026
99ceb23
Merge branch 'development' into reporting-section-schedule
DinuniWork Nov 19, 2026
d68761d
feat: update untranslated locales with additional language support
DinuniWork Nov 19, 2026
dc6c0c9
Merge branch 'reporting-section-schedule' of https://github.com/Workl…
DinuniWork Nov 19, 2026
a5e09a6
feat: enhance reporting analytics with scheduling features
DinuniWork Nov 19, 2026
329dd5f
feat: update localization for reporting analytics and enhance schedul…
DinuniWork Nov 19, 2026
eccbe12
feat: enhance analytics scheduling with multi-format support
DinuniWork Nov 19, 2026
c5955c3
feat: enhance PDF generation in analytics reports with new options
DinuniWork Nov 19, 2026
004e5e3
fix: update PDF generation styles and structure for improved layout
DinuniWork Nov 19, 2026
8dcd044
Merge branch 'development' of https://github.com/Worklenz/worklenz in…
DinuniWork Nov 19, 2026
e6c6bbd
chore: update google-auth-library to version 11.3.4 and adjust PDF ge…
DinuniWork Nov 19, 2026
88aea81
feat: enhance reporting components with new action icons and styles
DinuniWork Nov 19, 2026
d9e0f57
feat: enhance Project Health reporting with side-by-side chart rendering
DinuniWork Nov 19, 2026
16ca432
feat: improve Project Health Donut Chart export functionality
DinuniWork Nov 19, 2026
ae75716
feat: enhance Project Health Donut Chart styling for exports
DinuniWork Nov 19, 2026
0c13ef8
feat: improve chart rendering and PDF export quality in Project Healt…
DinuniWork Nov 20, 2026
ede53a4
refactor: remove exportedOn parameter from PDF header components
DinuniWork Nov 20, 2026
addc7eb
feat: enhance PDF reporting with filter details and chart titles
DinuniWork Nov 20, 2026
e788a60
feat: enhance reporting analytics with table cell color support
DinuniWork Nov 20, 2026
e7e8eaf
feat: enhance reporting analytics with variance days formatting
DinuniWork Nov 20, 2026
a634a6e
feat: update localization for reporting analytics in multiple languages
DinuniWork Nov 20, 2026
e1c9e8f
feat: enhance analytics report scheduling with HTML email formatting …
DinuniWork Nov 20, 2026
d378de2
feat: enhance reporting analytics with chart hints and legends for PD…
DinuniWork Nov 20, 2026
ebbd323
Merge branch 'development' of https://github.com/Worklenz/worklenz in…
DinuniWork Nov 20, 2026
ff9d795
Repair reports hub merge and translations
chamikaJ Nov 20, 2026
febbf67
Resolve committed backend lockfile conflict
chamikaJ Nov 20, 2026
16a1718
Fix analytics export and schedule review findings
chamikaJ Nov 20, 2026
d1ed181
Repair backend lockfile dependency resolution
chamikaJ Nov 20, 2026
e37369f
feat: enhance AllReportsPage with improved navigation and accessibility
DinuniWork Nov 20, 2026
e32b645
Restore unrelated dependency versions
chamikaJ Nov 20, 2026
3671552
Merge branch 'reporting-section-schedule' of https://github.com/Workl…
DinuniWork Nov 20, 2026
7be9af7
Merge branch 'reporting-section-schedule' of https://github.com/Workl…
DinuniWork Nov 20, 2026
c47abef
Fix merge conflicts in AllReportsPage.tsx by removing redundant code …
DinuniWork Nov 20, 2026
7e757bb
feat: implement finance schedule access control
DinuniWork Nov 20, 2026
50f7465
refactor: update schedule access control logic
DinuniWork Nov 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
"use strict";

/** @type {import('node-pg-migrate').ColumnDefinitions | undefined} */
exports.shorthands = undefined;

/**
* Recurring email schedules for analytics reports.
* Frequency fields mirror task_recurring_schedules (SCHEDULE_TYPE + day/interval
* columns). send_time is report-specific (recurring tasks have no time-of-day).
*
* @param {import('node-pg-migrate').MigrationBuilder} pgm
*/
exports.up = async (pgm) => {
pgm.sql(`
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'schedule_type') THEN
CREATE TYPE SCHEDULE_TYPE AS ENUM (
'daily',
'weekly',
'yearly',
'monthly',
'every_x_days',
'every_x_weeks',
'every_x_months'
);
END IF;
END
$$;

CREATE TABLE IF NOT EXISTS analytics_report_schedules (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
team_id UUID NOT NULL REFERENCES teams(id) ON DELETE CASCADE,
owner_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
report_kind VARCHAR(64) NOT NULL,
report_name VARCHAR(120) NOT NULL,
template_id UUID REFERENCES analytics_report_templates(id) ON DELETE CASCADE,

-- Recurrence (same shape as task_recurring_schedules)
schedule_type SCHEDULE_TYPE NOT NULL DEFAULT 'weekly'::SCHEDULE_TYPE,
days_of_week INTEGER[],
day_of_month INTEGER,
date_of_month INTEGER,
week_of_month INTEGER,
interval_days INTEGER,
interval_weeks INTEGER,
interval_months INTEGER,

-- Report schedules send at a clock time; recurring tasks do not
send_time TIME NOT NULL DEFAULT '08:00',
timezone VARCHAR(64) NOT NULL DEFAULT 'UTC',

recipients TEXT[] NOT NULL DEFAULT '{}',
format VARCHAR(16) NOT NULL DEFAULT 'PDF',
message TEXT,
filters_json JSONB NOT NULL DEFAULT '{}'::jsonb,

paused BOOLEAN NOT NULL DEFAULT FALSE,
last_sent_at TIMESTAMPTZ,
next_send_at TIMESTAMPTZ,

created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,

CONSTRAINT analytics_report_schedules_format_chk
CHECK (format IN ('PDF', 'CSV', 'Excel')),
CONSTRAINT analytics_report_schedules_recipients_chk
CHECK (cardinality(recipients) >= 1)
);

COMMENT ON TABLE analytics_report_schedules IS
'Email cadence for analytics reports. filters_json is fixed at save; export uses live data at send_time.';
COMMENT ON COLUMN analytics_report_schedules.filters_json IS
'Filter snapshot from the report page when the schedule was saved.';
COMMENT ON COLUMN analytics_report_schedules.send_time IS
'Local clock time in timezone when the live export should be emailed.';

CREATE UNIQUE INDEX IF NOT EXISTS idx_analytics_report_schedules_owner_kind_builtin
ON analytics_report_schedules(owner_id, report_kind)
WHERE template_id IS NULL;

CREATE UNIQUE INDEX IF NOT EXISTS idx_analytics_report_schedules_owner_template
ON analytics_report_schedules(owner_id, template_id)
WHERE template_id IS NOT NULL;

CREATE INDEX IF NOT EXISTS idx_analytics_report_schedules_team
ON analytics_report_schedules(team_id);

CREATE INDEX IF NOT EXISTS idx_analytics_report_schedules_due
ON analytics_report_schedules(next_send_at)
WHERE paused IS FALSE;
`);
};

/** @param {import('node-pg-migrate').MigrationBuilder} pgm */
exports.down = async (pgm) => {
pgm.sql(`
DROP INDEX IF EXISTS idx_analytics_report_schedules_due;
DROP INDEX IF EXISTS idx_analytics_report_schedules_team;
DROP INDEX IF EXISTS idx_analytics_report_schedules_owner_template;
DROP INDEX IF EXISTS idx_analytics_report_schedules_owner_kind_builtin;
DROP TABLE IF EXISTS analytics_report_schedules;
`);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"use strict";

/** @type {import('node-pg-migrate').ColumnDefinitions | undefined} */
exports.shorthands = undefined;

/**
* Allow multiple email schedules per report kind / template.
* Previously unique on (owner_id, report_kind) and (owner_id, template_id)
* limited each user to one schedule per report.
*
* @param {import('node-pg-migrate').MigrationBuilder} pgm
*/
exports.up = async (pgm) => {
pgm.sql(`
DROP INDEX IF EXISTS idx_analytics_report_schedules_owner_kind_builtin;

@superagent-security superagent-security Bot Nov 19, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Removing schedule uniqueness without a per-owner cap lets one member enqueue unbounded recurring export and email work

The migration removes schedule uniqueness and no per-owner cap is added, so one member can queue unlimited recurring exports and emails.

Enforce a per-owner/per-team schedule cap under a lock, rate-limit schedule creation, and give the cron a per-tenant fair-share budget.

AI prompt
Check if this security scanner issue is valid. If so, understand the root cause and fix it. If appropriate, update or add tests. Keep the change focused and preserve intended behavior.

<file name="worklenz-backend/database/pg-migrations/1794400000000_allow_multiple_analytics_report_schedules.js">
<violation number="1" location="worklenz-backend/database/pg-migrations/1794400000000_allow_multiple_analytics_report_schedules.js:15">
<priority>P2</priority>
<title>Removing schedule uniqueness without a per-owner cap lets one member enqueue unbounded recurring export and email work</title>
<evidence>The added migration drops the only uniqueness constraints on schedules (added line 15 drops idx_analytics_report_schedules_owner_kind_builtin and line 16 drops idx_analytics_report_schedules_owner_template, both UNIQUE in the preceding added migration) and replaces them with non-unique indexes (lines 18-23). upsertSchedule always performs a fresh INSERT (analytics-schedules.service.ts:597-653) and neither the service nor the controller enforces a per-owner, per-team or per-report schedule count. The only request-wide bound is the global 1,000 requests/minute limiter (app.ts:48-53), while each schedule may have MAX_RECIPIENTS = 25 recipients (analytics-schedules.service.ts:20) and up to three export formats. The added cron processes at most MAX_PER_TICK schedules per minute (default 10, maximum 50; cron_jobs/analytics-report-schedule-job.ts:17-21) under one global advisory lock, and processSchedule runs buildLiveScheduleExports (full analytics series queries plus chart rendering through chartjs-to-image/QuickChart, react-pdf/Excel generation) and then sends an email per recipient with attachments (analytics-report-schedule-job.ts:133-172). listDueSchedules selects due rows globally ordered by next_send_at with a LIMIT and no tenant fair share (analytics-schedules.service.ts:777-789), so one tenant's backlog delays every other tenant's due reports. Analytics templates have a per-user cap (MAX_ANALYTICS_TEMPLATES_PER_USER in src/shared/reporting-analytics.constants.ts:55-58), but schedules have no analogous cap.</evidence>
<recommendation>Enforce and validate a per-owner and per-team cap on active schedules under a transaction or advisory lock and reject creation above the cap. Add a dedicated rate limit to the schedule create/update routes and give the cron a per-tenant budget or fair-share queue so one member cannot monopolize the shared worker, QuickChart calls or SES quota. Bound total active schedules and recipients per tenant instead of relying on the global request limiter.</recommendation>
</violation>
</file>

DROP INDEX IF EXISTS idx_analytics_report_schedules_owner_template;

CREATE INDEX IF NOT EXISTS idx_analytics_report_schedules_owner_kind
ON analytics_report_schedules(owner_id, report_kind);

CREATE INDEX IF NOT EXISTS idx_analytics_report_schedules_owner_template
ON analytics_report_schedules(owner_id, template_id)
WHERE template_id IS NOT NULL;
`);
};

/** @param {import('node-pg-migrate').MigrationBuilder} pgm */
exports.down = async (pgm) => {
pgm.sql(`
DROP INDEX IF EXISTS idx_analytics_report_schedules_owner_template;
DROP INDEX IF EXISTS idx_analytics_report_schedules_owner_kind;

-- Recreate prior uniqueness (keeps the earliest row per owner/kind or template).
DELETE FROM analytics_report_schedules a
USING analytics_report_schedules b
WHERE a.owner_id = b.owner_id
AND a.template_id IS NULL
AND b.template_id IS NULL
AND a.report_kind = b.report_kind
AND a.created_at > b.created_at;

DELETE FROM analytics_report_schedules a
USING analytics_report_schedules b
WHERE a.owner_id = b.owner_id
AND a.template_id IS NOT NULL
AND b.template_id IS NOT NULL
AND a.template_id = b.template_id
AND a.created_at > b.created_at;

CREATE UNIQUE INDEX IF NOT EXISTS idx_analytics_report_schedules_owner_kind_builtin
ON analytics_report_schedules(owner_id, report_kind)
WHERE template_id IS NULL;

CREATE UNIQUE INDEX IF NOT EXISTS idx_analytics_report_schedules_owner_template
ON analytics_report_schedules(owner_id, template_id)
WHERE template_id IS NOT NULL;
`);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
"use strict";

/** @type {import('node-pg-migrate').ColumnDefinitions | undefined} */
exports.shorthands = undefined;

/**
* Allow multiple export formats per analytics report schedule.
* Migrates `format` VARCHAR → `formats` TEXT[].
*
* @param {import('node-pg-migrate').MigrationBuilder} pgm
*/
exports.up = async (pgm) => {
pgm.sql(`
ALTER TABLE analytics_report_schedules
ADD COLUMN IF NOT EXISTS formats TEXT[];

UPDATE analytics_report_schedules
SET formats = ARRAY[format]::TEXT[]
WHERE formats IS NULL;

ALTER TABLE analytics_report_schedules
ALTER COLUMN formats SET DEFAULT ARRAY['PDF']::TEXT[],
ALTER COLUMN formats SET NOT NULL;

ALTER TABLE analytics_report_schedules
DROP CONSTRAINT IF EXISTS analytics_report_schedules_format_chk;

ALTER TABLE analytics_report_schedules
DROP COLUMN IF EXISTS format;

ALTER TABLE analytics_report_schedules
ADD CONSTRAINT analytics_report_schedules_formats_chk
CHECK (
cardinality(formats) >= 1
AND formats <@ ARRAY['PDF', 'CSV', 'Excel']::TEXT[]
);
`);
};

/** @param {import('node-pg-migrate').MigrationBuilder} pgm */
exports.down = async (pgm) => {
pgm.sql(`
ALTER TABLE analytics_report_schedules
ADD COLUMN IF NOT EXISTS format VARCHAR(16);

UPDATE analytics_report_schedules
SET format = COALESCE(formats[1], 'PDF')
WHERE format IS NULL;

ALTER TABLE analytics_report_schedules
ALTER COLUMN format SET DEFAULT 'PDF',
ALTER COLUMN format SET NOT NULL;

ALTER TABLE analytics_report_schedules
DROP CONSTRAINT IF EXISTS analytics_report_schedules_formats_chk;

ALTER TABLE analytics_report_schedules
DROP COLUMN IF EXISTS formats;

ALTER TABLE analytics_report_schedules
ADD CONSTRAINT analytics_report_schedules_format_chk
CHECK (format IN ('PDF', 'CSV', 'Excel'));
`);
};
Loading
Loading