AI mentor wants you to put max records. So the aggregate needs to use amongst others for instance companies. So to give the aggregate a max record of companies we can use an aggregate to get a count of the number of companies that the system has. However, that aggregate needs a max records which for AI mentor we need to guess so we use 9999999. Is there a better way to do this?
The point of this rule is to make us think about how much records we really need.
The solution is to mark it as ,"won't fix" in AI Mentor Studio, if we really want our aggregate to fetch everything.
Any tricks ( large hardcoded number / site property / doing an extra count aggregate upfront ) are hiding the fact that we fetch everything.
A number of "won't fix" in AI Mentor Studio is superior to a number of obfuscated max record retrieves with these tricks.
Dorine
Hi @Klaus Geerthsen ,
In this case, It's better leave without the max records and ignore the warning in the AI mentor than set a random number, as Outsystems will manage better the query. Max. Records missing is just a recommendation to prevent excessive data retrieval, it's not mandatory to set it.
Kind Regards,
Tami
i think you can add some site property help you to make it dynamic somehow .
Hey @Klaus Geerthsen ,
The Count property of an aggregate gives you the total number of records no matter what you set for Max Records. So, a neat trick is to create an aggregate with Max Records set to 1 and use its Count value to set the Max Records for your main aggregate.
@Mihai Melencu ,
What would be the benefit of this? If you want it to retrieve everything, just leave MaxRecords empty.
Hey Dorine, there’s no real performance benefit to this, but it’s probably the best way to handle the feedback Klaus got from AI mentor about using max records without affecting performance.
Agreed with @Dorine Boudry . It doesn't make any sense to hardcode or use site properties to hiding the error in AI mentor.
Getting count only for the MaxRecords is more worse then other 2 option (one extra query just to hide a error).