Skip to content

Commit

Permalink
fix(ava/data): method to get the recommendation field type
Browse files Browse the repository at this point in the history
  • Loading branch information
LAI-X authored and chenluli committed Jun 20, 2023
1 parent 3a7c6f5 commit d564d7d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/ava/src/data/analysis/field/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,19 @@ export function analyzeField(
}
break;
case 2:
if (types.includes('integer') && types.includes('float')) recommendation = 'float';
else recommendation = 'string';
if (types.includes('integer') && types.includes('float')) {
recommendation = 'float';
break;
}
if (types.includes('integer') && types.includes('date')) {
// an integer field may be a date field
const data = list.filter((item) => item !== null);
if (data.map((num) => `${num}`).every((str) => isDateString(str))) {
recommendation = 'date';
break;
}
}
recommendation = 'string';
break;
default:
recommendation = 'string';
Expand Down

0 comments on commit d564d7d

Please sign in to comment.