Skip to content

Commit

Permalink
Add lowercase formatter in harvester
Browse files Browse the repository at this point in the history
This adds a new formatter to the harvesting fetch consumer to make
all values lowercase. For example, by convention we want all of our
AGROVOC subjects to be lower case, but we can't always update the
repository metadata ourselves. This allows us to normalize values
upon harvesting without having to create mappings.
  • Loading branch information
alanorth committed Nov 10, 2020
1 parent 9d4be9c commit 3816b9b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions backend/src/harvester/consumers/fetch.consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ export class FetchConsumer {
value = null;
}
}
if (addOn == "lowercase")
value = value.trim().toLowerCase();
}
}
return mapto[value] ? mapto[value] : value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ <h4 class="pt-5">Metadata fields</h4>
<mat-option value="language">Language</mat-option>
<mat-option value="country">Country</mat-option>
<mat-option value="date">Date</mat-option>
<mat-option value="lowercase">Lowercase</mat-option>
</mat-select>
</mat-form-field>
</div>
Expand Down

1 comment on commit 3816b9b

@alanorth
Copy link
Member Author

@alanorth alanorth commented on 3816b9b Nov 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @moayadnajd, check out my awesome TypeScript. I added a lowercase formatter so we can normalize AGROVOC subjects on import. 😜

Please sign in to comment.