Skip to content

Commit

Permalink
Merge pull request #591 from City-of-Helsinki/dev
Browse files Browse the repository at this point in the history
Dev to main
  • Loading branch information
rpnykanen authored Nov 5, 2024
2 parents db64b0f + 92f1b47 commit 21bca26
Show file tree
Hide file tree
Showing 14 changed files with 315 additions and 305 deletions.
2 changes: 1 addition & 1 deletion .platform/schema
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9
10
2 changes: 1 addition & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ services:
chromium:
# @todo Update this to newer version once minkphp supports Selenium 4.
# @see https://github.com/minkphp/MinkSelenium2Driver/pull/372
image: selenium/standalone-chrome:106.0
image: seleniarm/standalone-chromium:106.0
networks:
- internal
profiles:
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"drupal/helfi_tpr": "^2.0",
"drupal/helfi_tunnistamo": "^3.0",
"drupal/migrate_plus": "^6.0",
"drupal/raven": "^5.0",
"drupal/redis": "^1.5",
"drush/drush": "^12",
"google/apiclient": "^2.17"
Expand Down
496 changes: 252 additions & 244 deletions composer.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ id: linkedevents_event
label: 'LinkedEvents: Event'
label_plural: 'LinkedEvents: Events'
description: 'Event entities from https://api.hel.fi/linkedevents.'
generate_aliases: false
read_only: true
generate_aliases: false
field_mapper_id: jsonpath
field_mapper_config:
field_mappings:
Expand Down
2 changes: 1 addition & 1 deletion docker/openshift/crons/pubsub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ echo "Running PubSub daemon: $(date +'%Y-%m-%dT%H:%M:%S%:z')"

while true
do
# PubSub process exists with success return code after
# PubSub process exits with success return code after
# certain number of messages and should then be restarted.
drush helfi:azure:pubsub-listen || exit 1
done
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
use Drupal\Core\Utility\Token;
use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Exception\GuzzleException;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RequestStack;

Expand All @@ -35,14 +37,18 @@ final class HelfiHakuvahtiController extends ControllerBase {
* The token service.
* @param \Drupal\Core\Session\AccountInterface $user
* The current user.
* @param \Psr\Log\LoggerInterface $logger
* The logger.
*/
public function __construct(
protected ClientInterface $httpClient,
protected ContainerInterface $container,
protected RequestStack $requestStack,
protected Token $tokenService,
protected AccountInterface $user,
) {}
#[Autowire(service: 'logger.channel.helfi_hakuvahti')] private readonly LoggerInterface $logger,
) {
}

/**
* Handles the confirmation of a saved search.
Expand Down Expand Up @@ -148,7 +154,9 @@ protected function sendConfirmationRequest(string $subscriptionHash, string $sub
$response = $httpClient->get(getenv('HAKUVAHTI_URL') . "/subscription/confirm/{$subscriptionId}/{$subscriptionHash}");
return $response->getBody()->getContents() !== '';
}
catch (RequestException $exception) {
catch (GuzzleException $exception) {
$this->logger
->error('Hakuvahti confirmation request failed: ' . $exception->getMessage());
return FALSE;
}
}
Expand Down Expand Up @@ -259,7 +267,9 @@ protected function sendUnsubscribeRequest(string $hash, string $subscription): b
$response = $httpClient->delete(getenv('HAKUVAHTI_URL') . "/subscription/delete/{$subscription}/{$hash}");
return $response->getStatusCode() >= 200 && $response->getStatusCode() < 300;
}
catch (RequestException $exception) {
catch (GuzzleException $exception) {
$this->logger
->error('Hakuvahti unsubscribe request failed: ' . $exception->getMessage());
return FALSE;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public function post(): JsonResponse {
$bodyObj->search_description = $this->getSearchDescriptionTaxonomies($bodyObj);

$token = $request->headers->get('token');

// @todo Validate token.
//
// Somehow, we would need to validate token from
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,13 +529,6 @@ function helfi_rekry_content_page_attachments(array &$attachments) : void {
/** @var \Drupal\helfi_rekry_content\Entity\JobListing $job_listing */
$job_listing = $entity;

/** @var \Drupal\Core\Datetime\DateFormatterInterface $date_formatter */
$date_formatter = Drupal::service('date.formatter');

// @phpstan-ignore-next-line
$publication_starts_datetime = $job_listing->get('field_publication_starts')->date->getTimestamp();
$publication_starts_formatted = $date_formatter->format($publication_starts_datetime, 'html_date');

/** @var Drupal\Core\Extension\ThemeHandler $theme_handler */
$theme_handler = Drupal::service('theme_handler');

Expand Down Expand Up @@ -564,7 +557,7 @@ function helfi_rekry_content_page_attachments(array &$attachments) : void {
'name' => t('City of Helsinki'),
'value' => $job_listing->get('field_recruitment_id')->value,
],
'datePosted' => $publication_starts_formatted,
'datePosted' => $job_listing->getFormattedStartTime(),
'validThrough' => $job_listing->get('field_publication_ends')->value,
'employmentType' => $job_listing->getEmploymentType(),
'hiringOrganization' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ class JobListing extends Node {
* Job description.
*/
public function getJobDescription() : string {
return $this->get('field_job_description_override')->value ?: $this->get('job_description')->value;
return $this->get('field_job_description_override')->value
?: $this->get('job_description')->value
?? '';
}

/**
Expand Down Expand Up @@ -83,6 +85,27 @@ public function getEmploymentType() : string {

}

/**
* Create formatted datetime string for job listing formatted data.
*
* @return string
* A formatted date string.
*/
public function getFormattedStartTime(): string {
/** @var \Drupal\Core\Datetime\DateFormatterInterface $date_formatter */
$date_formatter = \Drupal::service('date.formatter');

if ($this->get('field_publication_starts')->isEmpty()) {
$publication_starts_datetime = $this->getCreatedTime();
}
else {
// @phpstan-ignore-next-line
$publication_starts_datetime = $this->get('field_publication_starts')->date->getTimestamp();
}

return $date_formatter->format($publication_starts_datetime, 'html_date');
}

/**
* Get city description fields.
*
Expand Down
2 changes: 1 addition & 1 deletion public/themes/custom/hdbt_subtheme/dist/css/styles.min.css

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions public/themes/custom/hdbt_subtheme/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,6 @@ $sort-minimum-width: 283px;
}
}

.job-listing-search__count-container {
@include font('lead');
margin-bottom: $spacing;

@include breakpoint($breakpoint-l) {
margin-bottom: 0;
}

.job-listing-search__count {
font-weight: $font-weight-bold;
}
}

.job-listing-search__sort {
min-width: $sort-minimum-width;
}
Expand Down Expand Up @@ -219,15 +206,3 @@ button.job-search-form__remove-selection-button:not(:disabled) {
outline-offset: $spacing-half;
}
}

.job-search__results-stats {
margin-bottom: $spacing-double;
margin-left: $spacing;
margin-right: $spacing;

@include breakpoint($breakpoint-l) {
align-items: flex-end;
display: flex;
justify-content: space-between;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
'views--' ~ id|clean_class,
'views--' ~ display_id|clean_class,
dom_id ? 'js-view-dom-id-' ~ dom_id,
'unit-search__content'
] %}

<div{{attributes.addClass(classes)}}>
Expand All @@ -51,20 +52,22 @@
{{ exposed }}
{{ attachment_before }}

<div class="job-listing-search__results">
<div class="job-listing-search__result-actions">
<span class="job-listing-search__count-container">
<span class="job-listing-search__count">{{ total_rows ?? 0 }}</span>
{% trans with {'context': 'Job listing search count'}%}open job listing{% plural total_rows ?? 0 %}open job listings{% endtrans %}
</span>
</div>
<div class="job-listing-search__result--list">
{{ rows }}
</div>
</div>
<div class="unit-search__results" data-id-number="{{ dom_id }}">
<h3 class="unit-search__count-container">
{%- if total_rows -%}
{{ total_rows }} {% trans with {'context': 'Job listing search count'}%}open job listing{% plural total_rows ?? 0 %}open job listings{% endtrans %}
{%- else -%}
{{ 'No results'|t({}, {'context' : 'Unit search no results title'}) }}
{%- endif -%}
</h3>

{%- if empty -%}
<p>{{ 'No results were found for the criteria you entered. Try changing your search criteria.'|t({}, {'context' : 'Unit search no results text'}) }}</p>
{%- endif -%}

{{ empty }}
{{ pager }}
{{ rows }}
{{ pager }}
</div>

{{ attachment_after }}
{{ more }}
Expand Down

0 comments on commit 21bca26

Please sign in to comment.