Sha256: 35a80d5da86a9d1769b77202acc8542d82c32584cd5b44fd2ae46275dd1ff890

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

export const flattenEntries = reports =>
  reports.reduce((memo, report) => [...memo, ...report.entries], []);

export const entryFixable = entry =>
  entry.detail &&
  entry.detail.remediations &&
  entry.detail.remediations.some(remediation => remediation.type === 'command');

export const isEmpty = obj => Object.keys(obj).length === 0;

export const anyEntriesFixable = reports =>
  flattenEntries(reports).some(entryFixable);

export const idsForInvocation = reports =>
  reports.reduce(
    (memo, report) => {
      report.entries.forEach(entry => {
        if (entryFixable(entry)) {
          memo.entryIds = [...memo.entryIds, entry.id];

          if (!memo.hostIds.includes(report.hostId)) {
            memo.hostIds = [...memo.hostIds, report.hostId];
          }
        }
      });
      return memo;
    },
    { hostIds: [], entryIds: [] }
  );

export const entriesPage = (entries, pagination) => {
  const offset = (pagination.page - 1) * pagination.perPage;

  return entries.slice(offset, offset + pagination.perPage);
};

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
foreman_leapp-0.0.6 webpack/components/PreupgradeReports/PreupgradeReportsHelpers.js