Skip to content

Commit

Permalink
change ad_id to project_id
Browse files Browse the repository at this point in the history
  • Loading branch information
Petter Andersson committed Oct 21, 2024
1 parent 40bfd6f commit 72511ba
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
22 changes: 22 additions & 0 deletions scripts/reachmee/helsingborg.se/run-local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"

if [ -z ${REACHMEE_HELSINGBORG_PATH} ]; then
echo "Missing env variable REACHMEE_HELSINGBORG_PATH"; exit 1
fi
which php
if [ $? -ne 0 ]; then
echo "PHP command missing or not in path"; exit 1
fi
cd ${SCRIPT_DIR}

# Retreive and transform Stratsys export
php ../../../router.php \
--source ${REACHMEE_HELSINGBORG_PATH} \
--transform jobposting \
--outputformat json \
--output '/tmp/reachmee.json'

if [ $? -ne 0 ]; then
echo "FAILED to transform request to file ${TMPFILE}"
fi
8 changes: 3 additions & 5 deletions src/Transforms/ReachmeeJobPostingTransform.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ class ReachmeeJobPostingTransform implements AbstractDataTransform
/**
* @param \SchemaTransformer\Interfaces\SanitizerInterface[] $sanitizers
*/
public function __construct(private array $sanitizers)
{
}
public function __construct(private array $sanitizers) {}

protected function normalizeArray(?array $in, int $length, array $fallback): array
{
Expand All @@ -41,14 +39,14 @@ public function transform(array $data): array
[$county, $city] = $this->normalizeArray($row['areas'] ?? [], 2, ["name" => ""]);
[$name, $unit] = $this->normalizeArray($row['organizations'] ?? [], 2, ["nameorgunit" => ""]);

if (empty($row['ad_id'])) {
if (empty($row['project_id'])) {
continue;
}

$directAppply = isset($row['hide_apply_button']) && !$row['hide_apply_button'] ? true : false;

$jobPosting = Schema::jobPosting()
->identifier((string) $row['ad_id'])
->identifier((string) $row['project_id'])
->title($row['title'] ?? null)
->employerOverview($row['prefix_text'] ?? null)
->description($row['description'] ?? null)
Expand Down
6 changes: 3 additions & 3 deletions tests/Transforms/ReachmeeJobPostingTransformTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ public function testJobPostingTransform(): void
$model = new ReachmeeJobPostingTransform([]);
$this->assertEquals([[
"@context" => "https://schema.org",
"@id" => "1",
"@version" => "4efca72bf3730a1043354801ec14268e",
"@id" => "2",
"@version" => "035ca770a4379fca08ba74934cfc30cb",
"@type" => "JobPosting",
"title" => "title",
"description" => "description",
Expand Down Expand Up @@ -148,7 +148,7 @@ public function testEmptyDataReturnsEmptyArray()

public function testSanitizertsAreApplied()
{
$data = [['ad_id' => 123, 'title' => 'original']];
$data = [['project_id' => 123, 'title' => 'original']];
$model = new ReachmeeJobPostingTransform([
new class {
public function sanitize(array $data): array
Expand Down

0 comments on commit 72511ba

Please sign in to comment.