Skip to content

[email protected]: Merge pull request #274 from Ferlab-Ste-Justine/fix/SJIP-389/boolean

Compare
Choose a tag to compare
@lflangis lflangis released this 01 May 17:05
· 480 commits to master since this release
dad147e

Migration Guide pour la 7.0.0

Actuellement, on cast chaque valeur 0 ou 1 en boolean, ce qui cause des conflits au niveau des chromosomes.

1 - Côté client, Ajouter key_as_string dans la requêtre des aggregas src/graphql/queries.ts

const generateAggregations = (extendedMappingFields: TExtendedMapping[]) => {
  const aggs = extendedMappingFields.map((f) => {
    if (['keyword', 'id'].includes(f.type)) {
      return (
        dotToUnderscore(f.field) +
        ' {\n     buckets {\n      key\n        key_as_string\n        doc_count\n    }\n  }'
      );
    } else if (['long', 'float', 'integer', 'date'].includes(f.type)) {
      return dotToUnderscore(f.field) + '{\n    stats {\n  max\n   min\n    }\n    }';
    } else if (['boolean'].includes(f.type)) {
      return (
        dotToUnderscore(f.field) +
        ' {\n      buckets {\n       key\n        key_as_string\n       doc_count\n     }\n    }'
      );
    } else {
      return '';
    }
  });
  return aggs.join(' ');
};

2 - Côté client, mettre à jour la fonction getFilters src/graphql/utils/Filters.tsx

export const getFilters = (aggregations: TAggregations | null, key: string): IFilter[] => {
  if (!aggregations || !key) return [];

  if (isTermAgg(aggregations[key])) {
    return aggregations[key!].buckets
      .map((f: any) => {
        const enhanceKey = f.key_as_string ?? f.key;
        const translatedKey = translateWhenNeeded(key, enhanceKey);
        const name = translatedKey ? translatedKey : enhanceKey;

        return {
          data: {
            count: f.doc_count,
            key: enhanceKey,
          },
          id: f.key,
          name: transformNameIfNeeded(key, name),
        };
      })
      .filter((f: any) => !(f.name === ''));
  } else if (aggregations[key]?.stats) {
    return [
      {
        data: { max: 1, min: 0 },
        id: key,
        name: translateWhenNeeded(key, key),
      },
    ];
  }
  return [];
};

3 - Mettre à jour ferlab-ui en version 7.