Skip to content

Commit

Permalink
add mapping to the transformer
Browse files Browse the repository at this point in the history
  • Loading branch information
alnutile committed Jun 19, 2023
1 parent 040e125 commit 15f785b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/Transformer/Types/JsonTransformer.php
Expand Up @@ -23,7 +23,7 @@ public function handle(Transformer $transformer): Document
->where('guid', $guid)
->exists()) {

if($mappings = data_get($transformer->meta_data, 'mappings')) {
if ($mappings = data_get($transformer->meta_data, 'mappings')) {
$content = json_decode($this->document->content, true);
$mapped = DataMapping::map($mappings, $content);
$fileContents = json_encode($mapped);
Expand Down
6 changes: 3 additions & 3 deletions tests/Feature/JsonTransformerTest.php
Expand Up @@ -34,15 +34,15 @@ public function test_runs_base_on_source()
$document = Document::factory()->create([
'source_id' => $source->id,
'guid' => 'foo.json',
'content' => json_encode($data)
'content' => json_encode($data),
]);

/** @var Transformer $transformer */
$transformerModel = Transformer::factory()->create([
'project_id' => $source->project_id,
'meta_data' => [
'mappings' => ['foo.baz', 'boo']
]
'mappings' => ['foo.baz', 'boo'],
],
]);

$this->assertDatabaseCount('document_chunks', 0);
Expand Down

0 comments on commit 15f785b

Please sign in to comment.