Skip to content
This repository has been archived by the owner on Aug 13, 2019. It is now read-only.

Commit

Permalink
III-1957: Index offer labels for exact matching
Browse files Browse the repository at this point in the history
  • Loading branch information
bertramakers committed Mar 14, 2017
1 parent e66566e commit d5bc101
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/Event/EventJsonDocumentTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function transform(JsonDocument $jsonDocument)
$this->copyName($body, $newBody);
$this->copyDescription($body, $newBody);

$this->copyLabels($body, $newBody);
$this->copyLabelsForFreeTextSearch($body, $newBody);
$this->copyTerms($body, $newBody);

Expand Down Expand Up @@ -71,5 +72,6 @@ private function copyLocation(\stdClass $from, \stdClass $to)

$this->copyIdentifiers($from->location, $to->location, 'Place');
$this->copyName($from->location, $to->location);
$this->copyLabels($from->location, $to->location);
}
}
15 changes: 15 additions & 0 deletions src/Offer/AbstractOfferJsonDocumentTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@ protected function copyDescription(\stdClass $from, \stdClass $to)
}
}

/**
* @param \stdClass $from
* @param \stdClass $to
*/
protected function copyLabels(\stdClass $from, \stdClass $to)
{
$labels = $this->getLabels($from);

if (!empty($labels)) {
$to->labels = $labels;
}
}

/**
* @param \stdClass $from
* @param \stdClass $to
Expand Down Expand Up @@ -181,5 +194,7 @@ protected function copyOrganizer(\stdClass $from, \stdClass $to)

$to->organizer->name = new \stdClass();
$to->organizer->name->nl = $from->organizer->name;

$this->copyLabels($from->organizer, $to->organizer);
}
}
1 change: 1 addition & 0 deletions src/Place/PlaceJsonDocumentTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function transform(JsonDocument $jsonDocument)
$this->copyName($body, $newBody);
$this->copyDescription($body, $newBody);

$this->copyLabels($body, $newBody);
$this->copyLabelsForFreeTextSearch($body, $newBody);
$this->copyTerms($body, $newBody);

Expand Down
22 changes: 20 additions & 2 deletions tests/Event/data/indexed-with-optional-fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
"en": "Some English description",
"de": "Some German description"
},
"labels": [
"visible label 1",
"visible label 2",
"hidden label 1",
"hidden label 2"
],
"labels_free_text": [
"visible label 1",
"visible label 2",
Expand Down Expand Up @@ -50,14 +56,26 @@
"fr": "French name for place",
"en": "English name for place",
"de": "German name for place"
}
},
"labels": [
"visible label 2",
"visible label 3",
"hidden label 2",
"hidden label 3"
]
},
"organizer": {
"@id": "http:\/\/udb-silex.dev\/organizers\/5e0b3f9c-5947-46a0-b8f2-a1a5a37f3b83",
"@type": "Organizer",
"id": "5e0b3f9c-5947-46a0-b8f2-a1a5a37f3b83",
"name": {
"nl": "PHPLeuven"
}
},
"labels": [
"visible label 4",
"visible label 5",
"hidden label 4",
"hidden label 5"
]
}
}
20 changes: 18 additions & 2 deletions tests/Event/data/original-with-optional-fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,27 @@
"geo": {
"latitude": 50.8876694,
"longitude": 4.70373
}
},
"labels": [
"visible label 2",
"visible label 3"
],
"hiddenLabels": [
"hidden label 2",
"hidden label 3"
]
},
"organizer": {
"@type": "Organizer",
"@id": "http://udb-silex.dev/organizers/5e0b3f9c-5947-46a0-b8f2-a1a5a37f3b83",
"name": "PHPLeuven"
"name": "PHPLeuven",
"labels": [
"visible label 4",
"visible label 5"
],
"hiddenLabels": [
"hidden label 4",
"hidden label 5"
]
}
}
14 changes: 13 additions & 1 deletion tests/Place/data/indexed-with-optional-fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
"en": "English description",
"de": "German description"
},
"labels": [
"visible label 1",
"visible label 2",
"hidden label 1",
"hidden label 2"
],
"labels_free_text": [
"visible label 1",
"visible label 2",
Expand All @@ -39,6 +45,12 @@
"id": "5e0b3f9c-5947-46a0-b8f2-a1a5a37f3b83",
"name": {
"nl": "PHPLeuven"
}
},
"labels": [
"visible label 3",
"visible label 4",
"hidden label 3",
"hidden label 4"
]
}
}
10 changes: 9 additions & 1 deletion tests/Place/data/original-with-optional-fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@
"organizer": {
"@type": "Organizer",
"@id": "http://udb-silex.dev/organizers/5e0b3f9c-5947-46a0-b8f2-a1a5a37f3b83",
"name": "PHPLeuven"
"name": "PHPLeuven",
"labels": [
"visible label 3",
"visible label 4"
],
"hiddenLabels": [
"hidden label 3",
"hidden label 4"
]
}
}

0 comments on commit d5bc101

Please sign in to comment.