mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-10-05 06:36: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
86 lines
2.4 KiB
AL
86 lines
2.4 KiB
AL
query 50127 "Perf Customer Chunk"
|
|
{
|
|
QueryType = Normal;
|
|
OrderBy = ascending(CustomerNo);
|
|
|
|
elements
|
|
{
|
|
dataitem(Customer; Customer)
|
|
{
|
|
column(CustomerNo; "No.") { }
|
|
}
|
|
}
|
|
}
|
|
|
|
codeunit 50128 "Perf Sample CommitInLoop Good"
|
|
{
|
|
procedure IncreaseCustomerCreditLimits()
|
|
var
|
|
CreditLimitState: Record "Perf Credit Limit State";
|
|
LastCustomerNo: Code[20];
|
|
begin
|
|
if not CreditLimitState.Get('CUSTOMER') then begin
|
|
CreditLimitState.Init();
|
|
CreditLimitState.Code := 'CUSTOMER';
|
|
CreditLimitState.Insert();
|
|
end;
|
|
LastCustomerNo := CreditLimitState."Last Customer No.";
|
|
|
|
while IncreaseNextChunk(LastCustomerNo) do begin
|
|
CreditLimitState."Last Customer No." := LastCustomerNo;
|
|
CreditLimitState.Modify();
|
|
Commit();
|
|
end;
|
|
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;
|
|
}
|
|
|
|
table 50128 "Perf Credit Limit State"
|
|
{
|
|
fields
|
|
{
|
|
field(1; Code; Code[10]) { }
|
|
field(2; "Last Customer No."; Code[20]) { }
|
|
}
|
|
|
|
keys
|
|
{
|
|
key(PK; Code) { Clustered = true; }
|
|
}
|
|
}
|