aoz-003 issueshttps://git.panter.ch/open-source/aoz-003/-/issues2023-02-09T09:52:25+01:00https://git.panter.ch/open-source/aoz-003/-/issues/476List group offers2023-02-09T09:52:25+01:00Kosta SimandirakisList group offershttps://git.panter.ch/open-source/aoz-003/-/issues/475Create Assignment2023-02-06T15:51:08+01:00Kosta SimandirakisCreate Assignmenthttps://git.panter.ch/open-source/aoz-003/-/issues/473Perf: Volunteer index - GET /volunteers2023-02-06T20:31:21+01:00Kaspar Vollenweidervok@panter.chPerf: Volunteer index - GET /volunteers[trace-volunteers-index-2023-01-17T210300_0100.log](/uploads/d3f11ac0dbccdaa14b26bc5fb5486967/trace-volunteers-index-2023-01-17T210300_0100.log)
```
GET /volunteers(.:format) volunteers#index
params:
controller: volunteers
action:...[trace-volunteers-index-2023-01-17T210300_0100.log](/uploads/d3f11ac0dbccdaa14b26bc5fb5486967/trace-volunteers-index-2023-01-17T210300_0100.log)
```
GET /volunteers(.:format) volunteers#index
params:
controller: volunteers
action: index
duration: 1.35086
Total allocated: 113.04 MB (978931 objects)
Total retained: 23.48 MB (44576 objects)
```
Quite a bit of performance and memory improvement can be achieved quickly [in the volunteers controller](https://git.panter.ch/open-source/aoz-003/-/blob/develop/app/controllers/volunteers_controller.rb#L8):
```ruby
@q = policy_scope(Volunteer).includes(
:clients, :assignments, :group_assignments, :user,
:contact, :language_skills
).ransack(params[:q])
```
https://git.panter.ch/open-source/aoz-003/-/commit/a639829a495f9766d7e79d44261fe7b4cef00d87
[trace-volunteers-index-2023-01-18T113030_0100.log](/uploads/6909efb727b25b65f3e62bcdbd8e0778/trace-volunteers-index-2023-01-18T113030_0100.log)
```
params:
controller: volunteers
action: index
duration: 0.755127
Total allocated: 28.51 MB (257107 objects)
Total retained: 1.28 MB (11105 objects)
```https://git.panter.ch/open-source/aoz-003/-/issues/472Perf: Download coplaner XLSX - GET /coplaners.xlsx2023-02-06T15:51:12+01:00Kaspar Vollenweidervok@panter.chPerf: Download coplaner XLSX - GET /coplaners.xlsxAction -> Remove realtime export
[trace-coplaner_exports-index-2023-01-17T212611_0100.log](/uploads/4d440154ec2fd673b11cda8afabd5e69/trace-coplaner_exports-index-2023-01-17T212611_0100.log)
```
GET /coplaners.xlsx coplaner_exports#i...Action -> Remove realtime export
[trace-coplaner_exports-index-2023-01-17T212611_0100.log](/uploads/4d440154ec2fd673b11cda8afabd5e69/trace-coplaner_exports-index-2023-01-17T212611_0100.log)
```
GET /coplaners.xlsx coplaner_exports#index
params:
controller: coplaner_exports
action: index
format: xlsx
duration: 341.732666
Total allocated: 10.49 GB (80210986 objects)
Total retained: 274.44 MB (2887910 objects)
```
This Excel download is so slow, because it produces one Excel file with many sheets inside (tabs).
## Produce each sheet for entity seperately
We could just as well produce each sheet in that excel separately into a file for each first, and then zip them into one sheet afterwards.
## SQL query optimizations
Plus some query optimizations using `.eager_load` or `.includes` and done as an active job, I'm sure this coplaner excel can be optimized to work with Heroku.https://git.panter.ch/open-source/aoz-003/-/issues/471Perf: GroupOffer edit - GET /group_offers/:id/edit2023-02-06T20:28:50+01:00Kaspar Vollenweidervok@panter.chPerf: GroupOffer edit - GET /group_offers/:id/edit[trace-group_offers-edit-2023-01-17T210610_0100.log](/uploads/5ae89e4122a68b48cc9c3e254299e3f1/trace-group_offers-edit-2023-01-17T210610_0100.log)
```
GET /group_offers/:id/edit group_offers#edit
params:
controller: group_offers
act...[trace-group_offers-edit-2023-01-17T210610_0100.log](/uploads/5ae89e4122a68b48cc9c3e254299e3f1/trace-group_offers-edit-2023-01-17T210610_0100.log)
```
GET /group_offers/:id/edit group_offers#edit
params:
controller: group_offers
action: edit
id: '78'
duration: 1.325926
Total allocated: 591.50 MB (603623 objects)
Total retained: 2.89 MB (24030 objects)
```https://git.panter.ch/open-source/aoz-003/-/issues/469Perf: SemesterProcess new - GET /semester_processes/new2023-02-06T20:47:37+01:00Kaspar Vollenweidervok@panter.chPerf: SemesterProcess new - GET /semester_processes/new[trace-semester_processes-new-2023-01-17T210705_0100.log](/uploads/1e6e78f0fc3e4543777601cc13790614/trace-semester_processes-new-2023-01-17T210705_0100.log)
```
GET /semester_processes/new(.:format) semester_processes#new
params:
se...[trace-semester_processes-new-2023-01-17T210705_0100.log](/uploads/1e6e78f0fc3e4543777601cc13790614/trace-semester_processes-new-2023-01-17T210705_0100.log)
```
GET /semester_processes/new(.:format) semester_processes#new
params:
semester: '2022,2'
controller: semester_processes
action: new
duration: 12.778534
Total allocated: 1.08 GB (4322312 objects)
Total retained: 23.47 MB (267841 objects)
```
Since this task is a periodic thing, they want to do on two dates during the year, I think this could be refactored to be prepared for them on the day they wish by scheduled task.
And I think the queries in there could probably also be faster, if `.eager_load` or `.includes` are done at the right places in the right manner.https://git.panter.ch/open-source/aoz-003/-/issues/468Perf: Volunteer edit - GET /volunteers/:id/edit2023-02-06T20:42:55+01:00Kaspar Vollenweidervok@panter.chPerf: Volunteer edit - GET /volunteers/:id/edit[trace-volunteers-edit-2023-01-17T204629_0100.log](/uploads/f29c290010224ae42d928ae57cba0ff3/trace-volunteers-edit-2023-01-17T204629_0100.log)
```
GET /volunteers/1855/edit
params:
controller: volunteers
action: edit
id: '1855'
du...[trace-volunteers-edit-2023-01-17T204629_0100.log](/uploads/f29c290010224ae42d928ae57cba0ff3/trace-volunteers-edit-2023-01-17T204629_0100.log)
```
GET /volunteers/1855/edit
params:
controller: volunteers
action: edit
id: '1855'
duration: 1.305161
Total allocated: 647.86 MB (1075908 objects)
Total retained: 23.85 MB (46115 objects)
```
Speed could be improved by doing `.eager_load` in the [volunteers_controller](https://git.panter.ch/open-source/aoz-003/-/blob/develop/app/controllers/volunteers_controller.rb#L164-167)
```ruby
def set_volunteer
v_scope = Volunteer.eager_load(group_assignments: [:trial_period, :group_offer])
.eager_load(:group_assignment_logs)
.eager_load(:assignment_logs)
.eager_load(
assignments: [
:trial_period,
client: [:contact,
involved_authority: [profile: [:contact]]],
creator: [profile: [:contact]]
]
)
.eager_load(:contact)
.eager_load(:relatives)
.eager_load(:group_offer_categories)
.eager_load(:language_skills)
if current_user.superadmin?
v_scope = v_scope.eager_load(invited_by: [profile: [:contact]])
.eager_load(accepted_by: [profile: [:contact]])
.eager_load(undecided_by: [profile: [:contact]])
.eager_load(rejected_by: [profile: [:contact]])
.eager_load(resigned_by: [profile: [:contact]])
end
@volunteer = v_scope.find(params[:id])
authorize @volunteer
end
```
0ac507a13d872f556243c71b5be14ed6712090ce
The memory trace with this and some template fixes is:
[trace-volunteers-edit-2023-01-18T113246_0100.log](/uploads/7dc5e373c05b4c0625943cb8a0cf6ade/trace-volunteers-edit-2023-01-18T113246_0100.log)
```
GET /volunteers/556/edit
params:
controller: volunteers
action: edit
id: '556'
duration: 0.88495
Total allocated: 553.58 MB (428570 objects)
Total retained: 2.74 MB (18512 objects)
```Heroku Deployable