Skip to content

Commit

Permalink
[PepperBridgeAbstract] Fix Detection of "no deals found" and more (RS…
Browse files Browse the repository at this point in the history
…S-Bridge#3821)

- CSS styles showing there were no deals found has changed : CSS class
  was updated
- Relative Date handling : the minimum granularity of a relative date is
  the minute on the site. Seconds are therefore meaningless, and are now deleted.

MydealsBridge was missing one relateve date prefix : now every date is
parsed (I hope so !)
  • Loading branch information
sysadminstory authored Dec 8, 2023
1 parent c3d9383 commit 3ef0226
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion bridges/MydealsBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -2068,7 +2068,9 @@ class MydealsBridge extends PepperBridgeAbstract
'relative-date-alt-prefixes' => [
'aktualisiert vor ',
'kommentiert vor ',
'heiß seit '
'eingestellt vor ',
'heiß seit ',
'vor '
],
'relative-date-ignore-suffix' => [
'/von.*$/'
Expand Down
8 changes: 7 additions & 1 deletion bridges/PepperBridgeAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected function collectDeals($url)
);

// If there is no results, we don't parse the content because it display some random deals
$noresult = $html->find('h3[class=size--all-l]', 0);
$noresult = $html->find('h3[class*=text--b]', 0);
if ($noresult != null && strpos($noresult->plaintext, $this->i8n('no-results')) !== false) {
$this->items = [];
} else {
Expand Down Expand Up @@ -542,6 +542,10 @@ private function relativeDateToTimestamp($str)
{
$date = new DateTime();

// The minimal amount of time substracted is a minute : the seconds in the resulting date would be related to the execution time of the script.
// This make no sense, so we set the seconds manually to "00".
$date->setTime($date->format('H'), $date->format('i'), 0);

// In case of update date, replace it by the regular relative date first word
$str = str_replace($this->i8n('relative-date-alt-prefixes'), $this->i8n('local-time-relative')[0], $str);

Expand All @@ -559,6 +563,8 @@ private function relativeDateToTimestamp($str)
''
];
$date->modify(str_replace($search, $replace, $str));


return $date->getTimestamp();
}

Expand Down

0 comments on commit 3ef0226

Please sign in to comment.