import { adapters } from '@/services/serviceConfig';
// Aggregate counts used on customer cards and customer detail.
export const workshopService = {
  customerCounts: async (customer_uuid) => {
    const [limbs, projects, orders, covers] = await Promise.all([
      adapters.database.filter('LimbProfile', { customer_uuid }),
      adapters.database.filter('CoverProject', { customer_uuid }),
      adapters.database.filter('Order', { customer_uuid }),
      adapters.database.filter('CompletedCover', { customer_uuid }),
    ]);
    return { limbs: limbs.length, projects: projects.length, orders: orders.length, covers: covers.length };
  },
  isFictional: (record) => {
    const o = record && record.data_origin;
    return o === 'Fictional Test Data' || o === 'Fictional';
  },
  hideFictional: (records) => (records || []).filter((r) => !workshopService.isFictional(r)),
};