注: 以下の翻訳の正確性は検証されていません。AIPを利用して英語版の原文から機械的に翻訳されたものです。
Typescript を使って、オブジェクトのリストを別のオブジェクトグループにラウンドロビン方式で割り当てるにはどうすればよいですか?
このコードは、アラートを AIP Analyst にラウンドロビン方式で割り当てるオントロジー編集関数を定義します。アラートを順に処理し、従業員IDに基づいて AIP Analyst に割り当てます。すべての AIP Analyst にアラートが割り当てられると、最初の AIP Analyst に戻ります。
Copied!1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20@OntologyEditFunction() @Edits(Alert) public async alertAssignment(alerts: Alert[]>): Promise<void>{ const analysts = Objects.search().analyst.all(); const numAnalysts = analysts.length; if(numAnalysts === 0){ return } let analystIndex = 0; for(const alert of alerts) { const employeeId = analysts.at(analystIndex)!.employeeId; alert.assignedTo = employeeId; analystIndex += 1; if (analystIndex === numAnalysts){ analystIndex = 0; } } }
functions on objects, typescript, alert, analyst, round-robinTypescript で2つのタイムスタンプ間の日数を計算するにはどうすればよいですか?
このコードは、2個のタイムスタンプオブジェクトを入力として受け取り、その間の日数を Integer として返す関数を定義します。
Copied!1 2 3 4 5 6 7import { Function, Integer, Timestamp} from "@foundry/functions-api"; @Function() public getDaysBetweenTimestamp(date1: Timestamp, date2: Timestamp): Integer{ return Math.floor((Math.abs((date1.getTime()-date2.getTime())) / (1000 * 3600 * 24))); }
typescript, functions on objects