Пример #1
0
const convertUsacEventToRcnEvent = previousEventsByPermit => rawUsacEvent => {
  const existingRcnEvents = previousEventsByPermit[trim(rawUsacEvent.permit)]

  const existingRcnEvent = existingRcnEvents
    ? (existingRcnEvents.length === 1)
      ? first(existingRcnEvents)
      // if multiple events, match by discipline, since ther ecould be same event for different disciplines
      : find(x => x.discipline === parseDiscipline(rawUsacEvent.discipline), existingRcnEvents)
  : undefined

  if (existingRcnEvent && existingRcnEvent.length > 1) {
    log.error('Found two existing events with same discipline and permit number, '
    + 'which means we should go to USAC and double-check WTF is going on. '
    + 'This could also mean that event has been moved to a different date '
    + 'and we need to add support for this.')
    log.debug(existingRcnEvent)
  }

  try {
    const rcnEvent = existingRcnEvent
      ? createUpdatedEvent(existingRcnEvent, rawUsacEvent)
      : createNewEvent(rawUsacEvent)

    return rcnEvent
  } catch (e) {
    log.error(e)
    log.error('Failed to parse event: ')
    log.error(rawUsacEvent)
  }
}
Пример #2
0
    traversal: (element) => {
      const spannedMeasures = _(element).spannedMeasures().value();
      const staffNs = _.staffNs(element);
      const getDescendantDurationals = flow(
        _.descendants,
        filter(allPass([isDurational, flow(_.staffN, (staffN) => includes(staffN, staffNs))]))
      );

      const durationals = flatMap(cond([
        [
          eq(first(spannedMeasures)),
          flow(getDescendantDurationals, filter(flow(_.tstamp, lte(_.startTstamp(element))))),
        ],
        [
          eq(last(spannedMeasures)),
          flow(getDescendantDurationals, filter(flow(_.tstamp, gte(_.endTstamp(element))))),
        ],
        [
          constant(true),
          getDescendantDurationals,
        ],
      ]), spannedMeasures);

      return durationals;
    },
Пример #3
0
 function everything(ps, truth) {
   if (isEmpty(ps)) {
     return truth
   } else {
     return every(argsArray, first(ps)) && everything(tail(ps), truth)
   }
 }
Пример #4
0
 function something(ps, truth) {
   if (isEmpty(ps)) {
     return truth
   } else {
     return some(argsArray, first(ps)) || something(tail(ps), truth)
   }
 }
Пример #5
0
function unzip(pairs) {
  if (isEmpty(pairs)) {
    return [[], []]
  }

  return constructPair(first(pairs), unzip(tail(pairs)))
}
Пример #6
0
  const queueComputation = () => {
    if (fiber !== null) return;
    const sectionId = first(keys(queuedInputs));
    if (!sectionId) return;

    /* eslint-disable no-use-before-define */
    fiber = runFiber(sectionComputation, ({
      sectionId,
      forceRecalculation: false,
      instance: getInstanceFor(sectionId),
      constants: getOr({}, sectionId, constantsPerSection),
      inputs: getOr([], sectionId, queuedInputs),
      previousResults: getOr([], sectionId, previousResultsPerSection),
      results: [],
    }: CalculationState));
    /* eslint-enable */
  };
Пример #7
0
 .then(machines => {
   const firstMachine = _.first(machines)
   if (!firstMachine) return res.status(404).send({Error: 'No machines'})
   return logs.getMachineLogs(firstMachine.deviceId)
     .then(r => res.send(r))
 })
Пример #8
0
const toUpperCaseFirst = string =>
  first(string).toUpperCase() + string.slice(1).toLowerCase()