1.2.15 • Published 1 year ago

@ythub/quota-matcher v1.2.15

Weekly downloads
-
License
UNLICENSED
Repository
github
Last release
1 year ago

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

1 year ago

1.2.12

1 year ago

1.2.13

1 year ago

1.2.14

1 year ago

1.2.8

4 years ago

1.2.9

4 years ago

1.2.10

4 years ago

1.2.11

4 years ago

1.2.7

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago