Replies: 2 comments
-
I think it doesn't work in the following cases:
Some side notesI think the time complexity of public static function fromRequestsAndResponses(Requests $requests, Responses $responses)
{
...
// current implementation:
foreach ($responses as $response) {
$matchingRequest = $requests->findBy(...); // uses array_filter() and although the name suggests it is a query operation it changes the requests by array_shift too.
}
// linear-time implementation: requests and responses should be made in a way such that requests[i] be always matched with response[i]
foreach ($responses as $key => $response) {
$matchingRequest = $requests[$key];
}
...
return self::withItems($reports);
} /**
* @param SendReport[] $items
*/
public static function withItems(array $items): self
{
$report = new self();
// current implementation (quadratic time unnecessarily complicated)
foreach ($items as $item) {
$report = $report->withAdded($item);
}
// simple implementation:
$report->items = $items;
return $report;
} |
Beta Was this translation helpful? Give feedback.
-
@halaei Sorry for the late reply! Could you please have look at #518? The array index based process that you initially asked about would only work if FCM processes the requests in the same order as we send them. That's why I went with a mapping based on the I hope this is a solution that works for you, let me know if you see further improvements or have other remarks 🙏. Thanks! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Given the following code from documentations
After
sendAll()
returns, I am wondering how can I match$sendReport
items to items of$messages
. Does the following always work?If so, it would be great to add this to the documentations. If not, then I guess it is a bug needed to be addressed.
Thanks
Beta Was this translation helpful? Give feedback.
All reactions