Skip to content

Commit

Permalink
Merge pull request #482 from Gapminder/fix-trans-dp-rule
Browse files Browse the repository at this point in the history
fixed(rule): wrong DUPLICATED_DATA_POINT_TRANSLATION_KEY rule behavior
  • Loading branch information
buchslava authored Feb 2, 2018
2 parents 985ff6f + e432108 commit 939d081
Show file tree
Hide file tree
Showing 32 changed files with 930 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"test-travis": "istanbul cover mocha _mocha -- -R spec --timeout 200000 --compilers ts:ts-node/register --recursive test/**/*.spec.ts && codecov",
"changelog": "conventional-changelog -i CHANGELOG.md -s -p angular",
"github-release": "conventional-github-releaser -p angular",
"build": "tsc && touch lib/package.json && echo \\{\\\"version\\\": \\\"1.11.0\\\"\\} > lib/package.json",
"build": "tsc && touch lib/package.json && echo \\{\\\"version\\\": \\\"1.12.0\\\"\\} > lib/package.json",
"prepublish": "npm run build",
"preversion": "npm test",
"version": "npm run changelog && git add CHANGELOG.md",
Expand Down
7 changes: 4 additions & 3 deletions src/data/ddf-root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ export class DDFRoot {
const translationFolder = resolve(this.path, TRNSLATIONS_FOLDER);

fileDescriptor.transFileDescriptors = translationsIds
.map(translationsId =>
.map(translationId =>
new FileDescriptor({
dir: resolve(translationFolder, translationsId),
dir: resolve(translationFolder, translationId),
file: fileDescriptor.file,
type: fileDescriptor.type,
primaryKey: fileDescriptor.primaryKey,
fullPath: resolve(translationFolder, translationsId, fileDescriptor.file),
fullPath: resolve(translationFolder, translationId, fileDescriptor.file),
translationId,
isTranslation: true
}));
});
Expand Down
2 changes: 2 additions & 0 deletions src/data/file-descriptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class FileDescriptor {
public csvChecker: CsvChecker;
public hasFirstLine: boolean;
public isTranslation: boolean;
public translationId: boolean;
public size: number;

constructor(data) {
Expand All @@ -62,6 +63,7 @@ export class FileDescriptor {
this.fullPath = data.fullPath;
this.csvChecker = new CsvChecker(this.fullPath);
this.hasFirstLine = false;
this.translationId = data.translationId;
this.isTranslation = data.isTranslation;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const rule = {
const sortedPrimaryKey = dataPointDescriptor.fileDescriptor.primaryKey.sort();
const dimensionData = sortedPrimaryKey.map(keyPart => `${keyPart}:${dataPointDescriptor.record[keyPart]}`).join(',');
const indicatorName = difference(dataPointDescriptor.fileDescriptor.headers, dataPointDescriptor.fileDescriptor.primaryKey).join(',');
const recordHash = `${dimensionData}@${indicatorName}`;
const recordHash = `${dimensionData}@${indicatorName}#${dataPointDescriptor.fileDescriptor.translationId}`;

if (storage.hash.has(recordHash)) {
storage.duplicatedHashes.push(recordHash);
Expand Down
Loading

0 comments on commit 939d081

Please sign in to comment.