@ythub/quota-matcher
TypeScript icon, indicating that this package has built-in type declarations

1.2.15 • Public • Published

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:
    // ...
}

Readme

Keywords

none

Package Sidebar

Install

npm i @ythub/quota-matcher

Weekly Downloads

1

Version

1.2.15

License

UNLICENSED

Unpacked Size

47.8 kB

Total Files

32

Last publish

Collaborators

  • youthink-devs