Skip to content

Exo 89624 - #139

Merged
mkrout merged 2 commits into
developfrom
EXO-89624
Aug 25, 2026
Merged

Exo 89624#139
mkrout merged 2 commits into
developfrom
EXO-89624

Conversation

@mkrout

@mkrout mkrout commented Aug 24, 2026

Copy link
Copy Markdown
Member

No description provided.

mkrout added 2 commits August 24, 2026 20:04
Prior to this, the timesheet export ("Export all" and "Export FR")
could take several minutes and time out in production when exporting a
long period or many users.

This is caused by an N+1 query pattern: for every exported record, the
backend reloaded the user's teams from the organization service (3
queries per record for the TS code generation), the teams of the
record's activity, the sales orders of every converted client and the
user's social identity, on top of the per-relation loading of each
record's JPA graph - roughly 5 to 10 queries per exported row.

This commit fixes the problem by loading each record's object graph in
a single SQL query (fetch joins in ActivityRecordDAO), converting
record lists with per-call caches (teams per user, teams per activity,
client DTOs and identity full names are now loaded once per distinct
value instead of once per record), and skipping the redundant count
query when the whole list is fetched without pagination. A timing log
(operation=get-records-list ... duration_ms) is also added on the
listing/export endpoint to monitor it in production.

Measured on the same 2436-record dataset, server-side export time goes
from ~2-3.2s to ~60-110ms locally; the gap is far larger in production
where every extra query pays real database latency.
The "Duplicate" action of the timesheet used to create a single copy of
an entry on one chosen date. The date picker of the duplication drawer
now accepts a date range: when two dates are selected, one copy of the
entry is created on every day of the range (bounds included) in a
single REST call, skipping Saturdays and Sundays unless the new
"Include weekends" checkbox is ticked. Selecting a single date keeps
the previous behavior.

The new endpoint POST activityrecord/range applies the same security
rules as the single-record creation (a non-manager can only create
records for himself), rejects invalid or reversed ranges and ranges
over 366 days with HTTP 400, and returns the number of created records
shown in the success message.
@mkrout
mkrout enabled auto-merge (rebase) August 24, 2026 19:07
@mkrout
mkrout requested a review from azayati August 24, 2026 19:16
@mkrout
mkrout merged commit 232ab01 into develop Aug 25, 2026
1 check passed
@mkrout
mkrout deleted the EXO-89624 branch August 25, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants