Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
NickPhura committed Oct 30, 2024
1 parent 1a4ab74 commit b253f48
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('import-captures-service', () => {
I2: { t: 'n', w: '90', v: 90 },
J2: { t: 's', v: 'release' },
K2: { t: 's', v: 'capture' },
A3: { z: 'yyyy-mm-dd', t: 'd', v: new Date('2024-10-11T07:00:00.000Z'), w: '2024-10-11' },
A3: { z: 'yyyy-mm-dd', t: 'd', v: new Date('2024-10-10T07:00:00.000Z'), w: '2024-10-10' },
B3: { t: 's', v: 'Carlita' },
D3: { t: 'n', w: '90', v: 90 },
E3: { t: 'n', w: '100', v: 100 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('ImportMarkingsStrategy', () => {
G1: { t: 's', v: 'PRIMARY_COLOUR' },
H1: { t: 's', v: 'SECONDARY_COLOUR' },
I1: { t: 's', v: 'DESCRIPTION' }, // testing alias works
A2: { z: 'dd/mm/yyyy', t: 'd', v: new Date('2024-10-10T07:00:00.000Z'), w: '2024-10-10' },
A2: { z: 'yyyy-mm-dd', t: 'd', v: new Date('2024-10-10T07:00:00.000Z'), w: '2024-10-10' },
B2: { t: 's', v: 'Carl' },
C2: { t: 's', v: '10:10:12' },
D2: { t: 's', v: 'Left ear' }, // testing case insensitivity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ describe('importMeasurementsStrategy', () => {
E1: { t: 's', v: 'skull condition' },
F1: { t: 's', v: 'unknown' },
A2: { t: 's', v: 'carl' },
B2: { t: 's', v: '2024-10-10T07:00:00.000Z' },
B2: { t: 's', v: '2024-10-10' },
C2: { t: 's', v: '10:10:12' },
D2: { t: 'n', w: '2', v: 2 },
E2: { t: 'n', w: '0', v: 'good' },
A3: { t: 's', v: 'carlita' },
B3: { z: 'm/d/yy', t: 'd', v: new Date('2024-10-10T07:00:00.000Z'), w: '10/10/24' },
B3: { z: 'yyyy-mm-dd', t: 'd', v: new Date('2024-10-10T07:00:00.000Z'), w: '2024-10-10' },
C3: { t: 's', v: '10:10:12' },
D3: { t: 'n', w: '2', v: 2 },
E3: { t: 'n', w: '0', v: 'good' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,27 +115,19 @@ export class ImportMeasurementsStrategy extends DBService implements CSVImportSt
row: Row,
critterAliasMap: Map<string, ICritterDetailed | undefined>
): { capture_id?: string; critter_id?: string; tsn?: string } {
console.log(JSON.stringify(row, null, 2));
const getColumnCell = generateColumnCellGetterFromColumnValidator(this.columnValidator);

const alias = getColumnCell<string>(row, 'ALIAS');
const captureDate = getColumnCell(row, 'CAPTURE_DATE');
const captureTime = getColumnCell(row, 'CAPTURE_TIME');

console.log(JSON.stringify(captureDate, null, 2));
console.log(JSON.stringify(captureTime, null, 2));

let capture_id, critter_id, tsn;

if (alias.cell) {
const critter = critterAliasMap.get(alias.cell.toLowerCase());

if (critter) {
console.log(JSON.stringify(critter?.captures, null, 2));
console.log(JSON.stringify(captureDate.cell, null, 2));
console.log(JSON.stringify(captureTime.cell, null, 2));
const captures = findCapturesFromDateTime(critter.captures, captureDate.cell, captureTime.cell);
console.log(JSON.stringify(captures, null, 2));
critter_id = critter.critter_id;
capture_id = captures.length === 1 ? captures[0].capture_id : undefined;
tsn = String(critter.itis_tsn); // Cast to string for convienience
Expand Down

0 comments on commit b253f48

Please sign in to comment.