mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-10-05 14:46:55 +01:00
Address Nikola's batching and UI-handler feedback on PR #132. Preserve existing false-positive guards and defer the unconfirmed IsHandled policy. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f841a18b-535a-498e-96f2-f279b5378da5
61 lines
1.7 KiB
AL
61 lines
1.7 KiB
AL
query 50127 "Perf Customer Chunk"
|
|
{
|
|
QueryType = Normal;
|
|
OrderBy = ascending(CustomerNo);
|
|
|
|
elements
|
|
{
|
|
dataitem(Customer; Customer)
|
|
{
|
|
column(CustomerNo; "No.") { }
|
|
}
|
|
}
|
|
}
|
|
|
|
codeunit 50129 "Perf Sample CommitInLoop Bad"
|
|
{
|
|
procedure IncreaseCustomerCreditLimits()
|
|
var
|
|
LastCustomerNo: Code[20];
|
|
begin
|
|
while IncreaseNextChunk(LastCustomerNo) do
|
|
Commit();
|
|
end;
|
|
|
|
local procedure IncreaseNextChunk(var LastCustomerNo: Code[20]): Boolean
|
|
var
|
|
Customer: Record Customer;
|
|
TempCustomer: Record Customer temporary;
|
|
CustomerChunk: Query "Perf Customer Chunk";
|
|
ChunkStartedAt: DateTime;
|
|
MaxChunkDuration: Duration;
|
|
begin
|
|
ChunkStartedAt := CurrentDateTime();
|
|
MaxChunkDuration := 60000;
|
|
CustomerChunk.TopNumberOfRows(500);
|
|
if LastCustomerNo <> '' then
|
|
CustomerChunk.SetFilter(CustomerNo, '>%1', LastCustomerNo);
|
|
CustomerChunk.Open();
|
|
while CustomerChunk.Read() do begin
|
|
TempCustomer.Init();
|
|
TempCustomer."No." := CustomerChunk.CustomerNo;
|
|
TempCustomer.Insert();
|
|
end;
|
|
CustomerChunk.Close();
|
|
|
|
if TempCustomer.IsEmpty() then
|
|
exit(false);
|
|
|
|
Customer.LockTable();
|
|
if TempCustomer.FindSet() then
|
|
repeat
|
|
if Customer.Get(TempCustomer."No.") then begin
|
|
Customer."Credit Limit (LCY)" += 100;
|
|
Customer.Modify();
|
|
end;
|
|
LastCustomerNo := TempCustomer."No.";
|
|
until (TempCustomer.Next() = 0) or (CurrentDateTime() - ChunkStartedAt >= MaxChunkDuration);
|
|
|
|
exit(true);
|
|
end;
|
|
}
|