Hi,
I'm building an app that would be used for work-related trips by employees of our company.
This is the database schema:

So what I do here is I get the last trip taken by the employee using the application, figure out if this is still the same work trip as before (if it wasn't finished), and finishes the trip if it was started on a different day (other than today), and also sets the current user (by getting info from O365).
Set(
LastTrip;
Last(
SortByColumns(
Filter(
'[dbo].[trip]';
user = Office365Users.MyProfileV2().mail
);
"user";
Descending
)
)
);;
Set(
TripID;
LastTrip.id
);;
If(
IsToday(LastTrip.start) && IsBlank(LastTrip.end);
Set(
Trip;
LastTrip
) && Navigate('Next Screen');
Navigate(Start)
);;
UpdateIf(
'[dbo].[trip]';
!IsToday(LastTrip.start) && IsBlank(LastTrip.end) && id = LastTrip.id;
{end: now}
);;
Set(
CurrentUser;
LookUp(
Employees;
Employee_E_Mail = Office365Users.MyProfileV2().mail
)
)My question is - all of this code is taking super long (about 30 seconds or even more), which is too much. The code triggers when you press the "Start APP" button, and then the user has to wait for at least 30 seconds.
Can this be optimised somehow? I know Filter can't be delegated - do I have any other options?
Thanks