This package is related to the Hub quotas. It contains utils which intended to evaluate which quotas are matching and which are not.
Usage example:
import { matchQuotasWithRespondent, QuotaMatchResult } from '@ythub/quota-matcher'
const ageQualificationId = '304';
const genderQualificationId = '197';
const outcome = matchQuotasWithRespondent(
// Respondent collection
{
[ageQualificationId]: 22,
[genderQualificationId]: 1857 /* male */
},
// Survey quotas collection
{
id: 1,
name: 'Male 18-24',
remainingCompletes: 10,
isMandatory: true,
isEnabled: true,
conditions: [
{
range: [{ to: 24, from: 18 }],
property: ageProperty,
},
{
options: [1857],
property: genderProperty,
},
],
}
)
switch (outcome.matchResult) {
case QuotaMatchResult.Eligible:
// outcome.eligibleQuotas
// ... do something
break
case QuotaMatchResult.Ineligible:
case QuotaMatchResult.Uncertain:
// ...
}