21 Commits

Author SHA1 Message Date
5b424a2345 Update packages and add composer install to update script 2026-01-22 08:43:19 +01:00
710c31551e Upgrade php to 8.4 2026-01-22 08:28:30 +01:00
0042fda5cc Fix product page not loading 2026-01-21 08:32:24 +01:00
646383fb6a Improved countries migration 2026-01-20 11:00:39 +01:00
f9c58edccd Improvements to handling countries. 2026-01-20 10:44:33 +01:00
9ec3291a6a Add stock to product. 2026-01-20 10:09:35 +01:00
373fd1641b Start working on handling multiple countries at once 2026-01-20 08:40:34 +01:00
46065dae1a Add stock to product. 2026-01-19 15:08:53 +01:00
295a968581 feature/handle-multiple-countries (#45)
Reviewed-on: #45
Co-authored-by: Krzysiej <krzysiej@gmail.com>
Co-committed-by: Krzysiej <krzysiej@gmail.com>
2026-01-17 17:07:40 +01:00
ebe40785fa Clear list cache after clicking on a star item. 2026-01-15 10:29:24 +01:00
4cf1c2f90b Clear list cache after clicking on a star item. 2026-01-15 08:47:17 +01:00
e40391eb4c Fix for the promo prices for items that never had promo. Add new screenshot file. Update bin/update script 2026-01-14 08:42:20 +01:00
4095037b69 Add bootstra *.map files 2026-01-13 08:43:41 +01:00
b7ebf7374a Handle gaps in chart data when the product disappeared from the store then appeared again. 2026-01-12 09:03:14 +01:00
45343c9121 Filer items that have currently the lowest price. 2026-01-11 10:32:29 +01:00
653f94f9c9 Update bootstrap and get local bootstrap js file. 2026-01-10 09:32:38 +01:00
632f76aceb Handle cache of main menu 2026-01-10 09:27:09 +01:00
cbf143c7a0 Handle lastSeen column and all the discontinued items. 2026-01-10 09:21:59 +01:00
7920172735 Handle lastSeen column and all the discontinued items. 2026-01-10 08:56:31 +01:00
914310dab8 Mark now lowest price as now lowest. 2026-01-09 08:54:34 +01:00
8e8ef8fe04 Increase speed of processing the prices and products. Because this is getting out of hand. 2026-01-08 17:18:46 +01:00
23 changed files with 496 additions and 357 deletions

View File

@@ -1,4 +1,4 @@
FROM php:8.3-cli
FROM php:8.4-cli
WORKDIR /usr/src/app
ENV PHP_MEMORY_LIMIT=1500M

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env bash
echo "Updating project"
git pull origin master
bin/cli rm -rf var/cache
bin/cacheclean
bin/composer install --no-dev
echo "Project updated"

467
composer.lock generated
View File

@@ -1796,22 +1796,21 @@
},
{
"name": "symfony/clock",
"version": "v7.4.0",
"version": "v8.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/clock.git",
"reference": "9169f24776edde469914c1e7a1442a50f7a4e110"
"reference": "832119f9b8dbc6c8e6f65f30c5969eca1e88764f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/clock/zipball/9169f24776edde469914c1e7a1442a50f7a4e110",
"reference": "9169f24776edde469914c1e7a1442a50f7a4e110",
"url": "https://api.github.com/repos/symfony/clock/zipball/832119f9b8dbc6c8e6f65f30c5969eca1e88764f",
"reference": "832119f9b8dbc6c8e6f65f30c5969eca1e88764f",
"shasum": ""
},
"require": {
"php": ">=8.2",
"psr/clock": "^1.0",
"symfony/polyfill-php83": "^1.28"
"php": ">=8.4",
"psr/clock": "^1.0"
},
"provide": {
"psr/clock-implementation": "1.0"
@@ -1850,7 +1849,7 @@
"time"
],
"support": {
"source": "https://github.com/symfony/clock/tree/v7.4.0"
"source": "https://github.com/symfony/clock/tree/v8.0.0"
},
"funding": [
{
@@ -1870,38 +1869,37 @@
"type": "tidelift"
}
],
"time": "2025-11-12T15:39:26+00:00"
"time": "2025-11-12T15:46:48+00:00"
},
{
"name": "symfony/config",
"version": "v7.4.3",
"version": "v8.0.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/config.git",
"reference": "800ce889e358a53a9678b3212b0c8cecd8c6aace"
"reference": "58063686fd7b8e676f14b5a4808cb85265c5216e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/config/zipball/800ce889e358a53a9678b3212b0c8cecd8c6aace",
"reference": "800ce889e358a53a9678b3212b0c8cecd8c6aace",
"url": "https://api.github.com/repos/symfony/config/zipball/58063686fd7b8e676f14b5a4808cb85265c5216e",
"reference": "58063686fd7b8e676f14b5a4808cb85265c5216e",
"shasum": ""
},
"require": {
"php": ">=8.2",
"php": ">=8.4",
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/filesystem": "^7.1|^8.0",
"symfony/polyfill-ctype": "~1.8"
"symfony/filesystem": "^7.4|^8.0",
"symfony/polyfill-ctype": "^1.8"
},
"conflict": {
"symfony/finder": "<6.4",
"symfony/service-contracts": "<2.5"
},
"require-dev": {
"symfony/event-dispatcher": "^6.4|^7.0|^8.0",
"symfony/finder": "^6.4|^7.0|^8.0",
"symfony/messenger": "^6.4|^7.0|^8.0",
"symfony/event-dispatcher": "^7.4|^8.0",
"symfony/finder": "^7.4|^8.0",
"symfony/messenger": "^7.4|^8.0",
"symfony/service-contracts": "^2.5|^3",
"symfony/yaml": "^6.4|^7.0|^8.0"
"symfony/yaml": "^7.4|^8.0"
},
"type": "library",
"autoload": {
@@ -1929,7 +1927,7 @@
"description": "Helps you find, load, combine, autofill and validate configuration values of any kind",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/config/tree/v7.4.3"
"source": "https://github.com/symfony/config/tree/v8.0.3"
},
"funding": [
{
@@ -1949,7 +1947,7 @@
"type": "tidelift"
}
],
"time": "2025-12-23T14:24:27+00:00"
"time": "2025-12-23T14:52:06+00:00"
},
{
"name": "symfony/console",
@@ -2051,39 +2049,36 @@
},
{
"name": "symfony/dependency-injection",
"version": "v7.4.3",
"version": "v8.0.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/dependency-injection.git",
"reference": "54122901b6d772e94f1e71a75e0533bc16563499"
"reference": "8db0d4c1dd4c533a29210c68074999ba45ad6d3e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/dependency-injection/zipball/54122901b6d772e94f1e71a75e0533bc16563499",
"reference": "54122901b6d772e94f1e71a75e0533bc16563499",
"url": "https://api.github.com/repos/symfony/dependency-injection/zipball/8db0d4c1dd4c533a29210c68074999ba45ad6d3e",
"reference": "8db0d4c1dd4c533a29210c68074999ba45ad6d3e",
"shasum": ""
},
"require": {
"php": ">=8.2",
"php": ">=8.4",
"psr/container": "^1.1|^2.0",
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/service-contracts": "^3.6",
"symfony/var-exporter": "^6.4.20|^7.2.5|^8.0"
"symfony/var-exporter": "^7.4|^8.0"
},
"conflict": {
"ext-psr": "<1.1|>=2",
"symfony/config": "<6.4",
"symfony/finder": "<6.4",
"symfony/yaml": "<6.4"
"ext-psr": "<1.1|>=2"
},
"provide": {
"psr/container-implementation": "1.1|2.0",
"symfony/service-implementation": "1.1|2.0|3.0"
},
"require-dev": {
"symfony/config": "^6.4|^7.0|^8.0",
"symfony/expression-language": "^6.4|^7.0|^8.0",
"symfony/yaml": "^6.4|^7.0|^8.0"
"symfony/config": "^7.4|^8.0",
"symfony/expression-language": "^7.4|^8.0",
"symfony/yaml": "^7.4|^8.0"
},
"type": "library",
"autoload": {
@@ -2111,7 +2106,7 @@
"description": "Allows you to standardize and centralize the way objects are constructed in your application",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/dependency-injection/tree/v7.4.3"
"source": "https://github.com/symfony/dependency-injection/tree/v8.0.3"
},
"funding": [
{
@@ -2131,7 +2126,7 @@
"type": "tidelift"
}
],
"time": "2025-12-28T10:55:46+00:00"
"time": "2025-12-23T14:52:06+00:00"
},
{
"name": "symfony/deprecation-contracts",
@@ -2280,33 +2275,32 @@
},
{
"name": "symfony/error-handler",
"version": "v7.4.0",
"version": "v8.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/error-handler.git",
"reference": "48be2b0653594eea32dcef130cca1c811dcf25c2"
"reference": "d77ec7dda0c274178745d152e82baf7ea827fd73"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/error-handler/zipball/48be2b0653594eea32dcef130cca1c811dcf25c2",
"reference": "48be2b0653594eea32dcef130cca1c811dcf25c2",
"url": "https://api.github.com/repos/symfony/error-handler/zipball/d77ec7dda0c274178745d152e82baf7ea827fd73",
"reference": "d77ec7dda0c274178745d152e82baf7ea827fd73",
"shasum": ""
},
"require": {
"php": ">=8.2",
"php": ">=8.4",
"psr/log": "^1|^2|^3",
"symfony/polyfill-php85": "^1.32",
"symfony/var-dumper": "^6.4|^7.0|^8.0"
"symfony/var-dumper": "^7.4|^8.0"
},
"conflict": {
"symfony/deprecation-contracts": "<2.5",
"symfony/http-kernel": "<6.4"
"symfony/deprecation-contracts": "<2.5"
},
"require-dev": {
"symfony/console": "^6.4|^7.0|^8.0",
"symfony/console": "^7.4|^8.0",
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/http-kernel": "^6.4|^7.0|^8.0",
"symfony/serializer": "^6.4|^7.0|^8.0",
"symfony/http-kernel": "^7.4|^8.0",
"symfony/serializer": "^7.4|^8.0",
"symfony/webpack-encore-bundle": "^1.0|^2.0"
},
"bin": [
@@ -2338,7 +2332,7 @@
"description": "Provides tools to manage errors and ease debugging PHP code",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/error-handler/tree/v7.4.0"
"source": "https://github.com/symfony/error-handler/tree/v8.0.0"
},
"funding": [
{
@@ -2358,28 +2352,28 @@
"type": "tidelift"
}
],
"time": "2025-11-05T14:29:59+00:00"
"time": "2025-11-05T14:36:47+00:00"
},
{
"name": "symfony/event-dispatcher",
"version": "v7.4.0",
"version": "v8.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
"reference": "9dddcddff1ef974ad87b3708e4b442dc38b2261d"
"reference": "573f95783a2ec6e38752979db139f09fec033f03"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/9dddcddff1ef974ad87b3708e4b442dc38b2261d",
"reference": "9dddcddff1ef974ad87b3708e4b442dc38b2261d",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/573f95783a2ec6e38752979db139f09fec033f03",
"reference": "573f95783a2ec6e38752979db139f09fec033f03",
"shasum": ""
},
"require": {
"php": ">=8.2",
"php": ">=8.4",
"symfony/event-dispatcher-contracts": "^2.5|^3"
},
"conflict": {
"symfony/dependency-injection": "<6.4",
"symfony/security-http": "<7.4",
"symfony/service-contracts": "<2.5"
},
"provide": {
@@ -2388,14 +2382,14 @@
},
"require-dev": {
"psr/log": "^1|^2|^3",
"symfony/config": "^6.4|^7.0|^8.0",
"symfony/dependency-injection": "^6.4|^7.0|^8.0",
"symfony/error-handler": "^6.4|^7.0|^8.0",
"symfony/expression-language": "^6.4|^7.0|^8.0",
"symfony/framework-bundle": "^6.4|^7.0|^8.0",
"symfony/http-foundation": "^6.4|^7.0|^8.0",
"symfony/config": "^7.4|^8.0",
"symfony/dependency-injection": "^7.4|^8.0",
"symfony/error-handler": "^7.4|^8.0",
"symfony/expression-language": "^7.4|^8.0",
"symfony/framework-bundle": "^7.4|^8.0",
"symfony/http-foundation": "^7.4|^8.0",
"symfony/service-contracts": "^2.5|^3",
"symfony/stopwatch": "^6.4|^7.0|^8.0"
"symfony/stopwatch": "^7.4|^8.0"
},
"type": "library",
"autoload": {
@@ -2423,7 +2417,7 @@
"description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/event-dispatcher/tree/v7.4.0"
"source": "https://github.com/symfony/event-dispatcher/tree/v8.0.0"
},
"funding": [
{
@@ -2443,7 +2437,7 @@
"type": "tidelift"
}
],
"time": "2025-10-28T09:38:46+00:00"
"time": "2025-10-30T14:17:19+00:00"
},
{
"name": "symfony/event-dispatcher-contracts",
@@ -2523,25 +2517,25 @@
},
{
"name": "symfony/filesystem",
"version": "v7.4.0",
"version": "v8.0.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
"reference": "d551b38811096d0be9c4691d406991b47c0c630a"
"reference": "d937d400b980523dc9ee946bb69972b5e619058d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/d551b38811096d0be9c4691d406991b47c0c630a",
"reference": "d551b38811096d0be9c4691d406991b47c0c630a",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/d937d400b980523dc9ee946bb69972b5e619058d",
"reference": "d937d400b980523dc9ee946bb69972b5e619058d",
"shasum": ""
},
"require": {
"php": ">=8.2",
"php": ">=8.4",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-mbstring": "~1.8"
},
"require-dev": {
"symfony/process": "^6.4|^7.0|^8.0"
"symfony/process": "^7.4|^8.0"
},
"type": "library",
"autoload": {
@@ -2569,7 +2563,7 @@
"description": "Provides basic utilities for the filesystem",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/filesystem/tree/v7.4.0"
"source": "https://github.com/symfony/filesystem/tree/v8.0.1"
},
"funding": [
{
@@ -2589,27 +2583,27 @@
"type": "tidelift"
}
],
"time": "2025-11-27T13:27:24+00:00"
"time": "2025-12-01T09:13:36+00:00"
},
{
"name": "symfony/finder",
"version": "v7.4.3",
"version": "v8.0.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "fffe05569336549b20a1be64250b40516d6e8d06"
"reference": "dd3a2953570a283a2ba4e17063bb98c734cf5b12"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/fffe05569336549b20a1be64250b40516d6e8d06",
"reference": "fffe05569336549b20a1be64250b40516d6e8d06",
"url": "https://api.github.com/repos/symfony/finder/zipball/dd3a2953570a283a2ba4e17063bb98c734cf5b12",
"reference": "dd3a2953570a283a2ba4e17063bb98c734cf5b12",
"shasum": ""
},
"require": {
"php": ">=8.2"
"php": ">=8.4"
},
"require-dev": {
"symfony/filesystem": "^6.4|^7.0|^8.0"
"symfony/filesystem": "^7.4|^8.0"
},
"type": "library",
"autoload": {
@@ -2637,7 +2631,7 @@
"description": "Finds files and directories via an intuitive fluent interface",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/finder/tree/v7.4.3"
"source": "https://github.com/symfony/finder/tree/v8.0.3"
},
"funding": [
{
@@ -2657,7 +2651,7 @@
"type": "tidelift"
}
],
"time": "2025-12-23T14:50:43+00:00"
"time": "2025-12-23T14:52:06+00:00"
},
{
"name": "symfony/framework-bundle",
@@ -2819,37 +2813,35 @@
},
{
"name": "symfony/http-foundation",
"version": "v7.4.3",
"version": "v8.0.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-foundation.git",
"reference": "a70c745d4cea48dbd609f4075e5f5cbce453bd52"
"reference": "514ec3aa7982f296b0ad0825f75b6be5779ae9e7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/a70c745d4cea48dbd609f4075e5f5cbce453bd52",
"reference": "a70c745d4cea48dbd609f4075e5f5cbce453bd52",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/514ec3aa7982f296b0ad0825f75b6be5779ae9e7",
"reference": "514ec3aa7982f296b0ad0825f75b6be5779ae9e7",
"shasum": ""
},
"require": {
"php": ">=8.2",
"symfony/deprecation-contracts": "^2.5|^3",
"php": ">=8.4",
"symfony/polyfill-mbstring": "^1.1"
},
"conflict": {
"doctrine/dbal": "<3.6",
"symfony/cache": "<6.4.12|>=7.0,<7.1.5"
"doctrine/dbal": "<4.3"
},
"require-dev": {
"doctrine/dbal": "^3.6|^4",
"doctrine/dbal": "^4.3",
"predis/predis": "^1.1|^2.0",
"symfony/cache": "^6.4.12|^7.1.5|^8.0",
"symfony/clock": "^6.4|^7.0|^8.0",
"symfony/dependency-injection": "^6.4|^7.0|^8.0",
"symfony/expression-language": "^6.4|^7.0|^8.0",
"symfony/http-kernel": "^6.4|^7.0|^8.0",
"symfony/mime": "^6.4|^7.0|^8.0",
"symfony/rate-limiter": "^6.4|^7.0|^8.0"
"symfony/cache": "^7.4|^8.0",
"symfony/clock": "^7.4|^8.0",
"symfony/dependency-injection": "^7.4|^8.0",
"symfony/expression-language": "^7.4|^8.0",
"symfony/http-kernel": "^7.4|^8.0",
"symfony/mime": "^7.4|^8.0",
"symfony/rate-limiter": "^7.4|^8.0"
},
"type": "library",
"autoload": {
@@ -2877,7 +2869,7 @@
"description": "Defines an object-oriented layer for the HTTP specification",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/http-foundation/tree/v7.4.3"
"source": "https://github.com/symfony/http-foundation/tree/v8.0.3"
},
"funding": [
{
@@ -2897,7 +2889,7 @@
"type": "tidelift"
}
],
"time": "2025-12-23T14:23:49+00:00"
"time": "2025-12-23T14:52:06+00:00"
},
{
"name": "symfony/http-kernel",
@@ -3020,28 +3012,27 @@
},
{
"name": "symfony/intl",
"version": "v7.4.0",
"version": "v8.0.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/intl.git",
"reference": "2fa074de6c7faa6b54f2891fc22708f42245ed5c"
"reference": "f9eca217ae8f2be0b3ad80723d6a3b518b90cd66"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/intl/zipball/2fa074de6c7faa6b54f2891fc22708f42245ed5c",
"reference": "2fa074de6c7faa6b54f2891fc22708f42245ed5c",
"url": "https://api.github.com/repos/symfony/intl/zipball/f9eca217ae8f2be0b3ad80723d6a3b518b90cd66",
"reference": "f9eca217ae8f2be0b3ad80723d6a3b518b90cd66",
"shasum": ""
},
"require": {
"php": ">=8.2",
"symfony/deprecation-contracts": "^2.5|^3"
"php": ">=8.4"
},
"conflict": {
"symfony/string": "<7.1"
"symfony/string": "<7.4"
},
"require-dev": {
"symfony/filesystem": "^6.4|^7.0|^8.0",
"symfony/var-exporter": "^6.4|^7.0|^8.0"
"symfony/filesystem": "^7.4|^8.0",
"symfony/var-exporter": "^7.4|^8.0"
},
"type": "library",
"autoload": {
@@ -3086,7 +3077,7 @@
"localization"
],
"support": {
"source": "https://github.com/symfony/intl/tree/v7.4.0"
"source": "https://github.com/symfony/intl/tree/v8.0.1"
},
"funding": [
{
@@ -3106,7 +3097,7 @@
"type": "tidelift"
}
],
"time": "2025-11-27T13:27:24+00:00"
"time": "2025-12-01T09:13:36+00:00"
},
{
"name": "symfony/polyfill-ctype",
@@ -3443,86 +3434,6 @@
],
"time": "2024-12-23T08:48:59+00:00"
},
{
"name": "symfony/polyfill-php83",
"version": "v1.33.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php83.git",
"reference": "17f6f9a6b1735c0f163024d959f700cfbc5155e5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php83/zipball/17f6f9a6b1735c0f163024d959f700cfbc5155e5",
"reference": "17f6f9a6b1735c0f163024d959f700cfbc5155e5",
"shasum": ""
},
"require": {
"php": ">=7.2"
},
"type": "library",
"extra": {
"thanks": {
"url": "https://github.com/symfony/polyfill",
"name": "symfony/polyfill"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Php83\\": ""
},
"classmap": [
"Resources/stubs"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill backporting some PHP 8.3+ features to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"polyfill",
"portable",
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php83/tree/v1.33.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://github.com/nicolas-grekas",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2025-07-08T02:45:35+00:00"
},
{
"name": "symfony/polyfill-php85",
"version": "v1.33.0",
@@ -3777,35 +3688,34 @@
},
{
"name": "symfony/string",
"version": "v7.4.0",
"version": "v8.0.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
"reference": "d50e862cb0a0e0886f73ca1f31b865efbb795003"
"reference": "ba65a969ac918ce0cc3edfac6cdde847eba231dc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/string/zipball/d50e862cb0a0e0886f73ca1f31b865efbb795003",
"reference": "d50e862cb0a0e0886f73ca1f31b865efbb795003",
"url": "https://api.github.com/repos/symfony/string/zipball/ba65a969ac918ce0cc3edfac6cdde847eba231dc",
"reference": "ba65a969ac918ce0cc3edfac6cdde847eba231dc",
"shasum": ""
},
"require": {
"php": ">=8.2",
"symfony/deprecation-contracts": "^2.5|^3.0",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-intl-grapheme": "~1.33",
"symfony/polyfill-intl-normalizer": "~1.0",
"symfony/polyfill-mbstring": "~1.0"
"php": ">=8.4",
"symfony/polyfill-ctype": "^1.8",
"symfony/polyfill-intl-grapheme": "^1.33",
"symfony/polyfill-intl-normalizer": "^1.0",
"symfony/polyfill-mbstring": "^1.0"
},
"conflict": {
"symfony/translation-contracts": "<2.5"
},
"require-dev": {
"symfony/emoji": "^7.1|^8.0",
"symfony/http-client": "^6.4|^7.0|^8.0",
"symfony/intl": "^6.4|^7.0|^8.0",
"symfony/emoji": "^7.4|^8.0",
"symfony/http-client": "^7.4|^8.0",
"symfony/intl": "^7.4|^8.0",
"symfony/translation-contracts": "^2.5|^3.0",
"symfony/var-exporter": "^6.4|^7.0|^8.0"
"symfony/var-exporter": "^7.4|^8.0"
},
"type": "library",
"autoload": {
@@ -3844,7 +3754,7 @@
"utf8"
],
"support": {
"source": "https://github.com/symfony/string/tree/v7.4.0"
"source": "https://github.com/symfony/string/tree/v8.0.1"
},
"funding": [
{
@@ -3864,38 +3774,31 @@
"type": "tidelift"
}
],
"time": "2025-11-27T13:27:24+00:00"
"time": "2025-12-01T09:13:36+00:00"
},
{
"name": "symfony/translation",
"version": "v7.4.3",
"version": "v8.0.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation.git",
"reference": "7ef27c65d78886f7599fdd5c93d12c9243ecf44d"
"reference": "60a8f11f0e15c48f2cc47c4da53873bb5b62135d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/7ef27c65d78886f7599fdd5c93d12c9243ecf44d",
"reference": "7ef27c65d78886f7599fdd5c93d12c9243ecf44d",
"url": "https://api.github.com/repos/symfony/translation/zipball/60a8f11f0e15c48f2cc47c4da53873bb5b62135d",
"reference": "60a8f11f0e15c48f2cc47c4da53873bb5b62135d",
"shasum": ""
},
"require": {
"php": ">=8.2",
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/polyfill-mbstring": "~1.0",
"symfony/translation-contracts": "^2.5.3|^3.3"
"php": ">=8.4",
"symfony/polyfill-mbstring": "^1.0",
"symfony/translation-contracts": "^3.6.1"
},
"conflict": {
"nikic/php-parser": "<5.0",
"symfony/config": "<6.4",
"symfony/console": "<6.4",
"symfony/dependency-injection": "<6.4",
"symfony/http-client-contracts": "<2.5",
"symfony/http-kernel": "<6.4",
"symfony/service-contracts": "<2.5",
"symfony/twig-bundle": "<6.4",
"symfony/yaml": "<6.4"
"symfony/service-contracts": "<2.5"
},
"provide": {
"symfony/translation-implementation": "2.3|3.0"
@@ -3903,17 +3806,17 @@
"require-dev": {
"nikic/php-parser": "^5.0",
"psr/log": "^1|^2|^3",
"symfony/config": "^6.4|^7.0|^8.0",
"symfony/console": "^6.4|^7.0|^8.0",
"symfony/dependency-injection": "^6.4|^7.0|^8.0",
"symfony/finder": "^6.4|^7.0|^8.0",
"symfony/config": "^7.4|^8.0",
"symfony/console": "^7.4|^8.0",
"symfony/dependency-injection": "^7.4|^8.0",
"symfony/finder": "^7.4|^8.0",
"symfony/http-client-contracts": "^2.5|^3.0",
"symfony/http-kernel": "^6.4|^7.0|^8.0",
"symfony/intl": "^6.4|^7.0|^8.0",
"symfony/http-kernel": "^7.4|^8.0",
"symfony/intl": "^7.4|^8.0",
"symfony/polyfill-intl-icu": "^1.21",
"symfony/routing": "^6.4|^7.0|^8.0",
"symfony/routing": "^7.4|^8.0",
"symfony/service-contracts": "^2.5|^3",
"symfony/yaml": "^6.4|^7.0|^8.0"
"symfony/yaml": "^7.4|^8.0"
},
"type": "library",
"autoload": {
@@ -3944,7 +3847,7 @@
"description": "Provides tools to internationalize your application",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/translation/tree/v7.4.3"
"source": "https://github.com/symfony/translation/tree/v8.0.3"
},
"funding": [
{
@@ -3964,7 +3867,7 @@
"type": "tidelift"
}
],
"time": "2025-12-29T09:31:36+00:00"
"time": "2025-12-21T10:59:45+00:00"
},
{
"name": "symfony/translation-contracts",
@@ -4050,67 +3953,58 @@
},
{
"name": "symfony/twig-bridge",
"version": "v7.4.3",
"version": "v8.0.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/twig-bridge.git",
"reference": "43c922fce020060c65b0fd54bfd8def3b38949b6"
"reference": "2a2978a44127bae9aaee0ed5319954eb492d81c3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/twig-bridge/zipball/43c922fce020060c65b0fd54bfd8def3b38949b6",
"reference": "43c922fce020060c65b0fd54bfd8def3b38949b6",
"url": "https://api.github.com/repos/symfony/twig-bridge/zipball/2a2978a44127bae9aaee0ed5319954eb492d81c3",
"reference": "2a2978a44127bae9aaee0ed5319954eb492d81c3",
"shasum": ""
},
"require": {
"php": ">=8.2",
"symfony/deprecation-contracts": "^2.5|^3",
"php": ">=8.4",
"symfony/translation-contracts": "^2.5|^3",
"twig/twig": "^3.21"
},
"conflict": {
"phpdocumentor/reflection-docblock": "<3.2.2",
"phpdocumentor/type-resolver": "<1.4.0",
"symfony/console": "<6.4",
"symfony/form": "<6.4",
"symfony/http-foundation": "<6.4",
"symfony/http-kernel": "<6.4",
"symfony/mime": "<6.4",
"symfony/serializer": "<6.4",
"symfony/translation": "<6.4",
"symfony/workflow": "<6.4"
"phpdocumentor/type-resolver": "<1.4.0"
},
"require-dev": {
"egulias/email-validator": "^2.1.10|^3|^4",
"league/html-to-markdown": "^5.0",
"phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0",
"symfony/asset": "^6.4|^7.0|^8.0",
"symfony/asset-mapper": "^6.4|^7.0|^8.0",
"symfony/console": "^6.4|^7.0|^8.0",
"symfony/dependency-injection": "^6.4|^7.0|^8.0",
"symfony/emoji": "^7.1|^8.0",
"symfony/expression-language": "^6.4|^7.0|^8.0",
"symfony/finder": "^6.4|^7.0|^8.0",
"symfony/form": "^6.4.30|~7.3.8|^7.4.1|^8.0.1",
"symfony/html-sanitizer": "^6.4|^7.0|^8.0",
"symfony/http-foundation": "^7.3|^8.0",
"symfony/http-kernel": "^6.4|^7.0|^8.0",
"symfony/intl": "^6.4|^7.0|^8.0",
"symfony/mime": "^6.4|^7.0|^8.0",
"symfony/polyfill-intl-icu": "~1.0",
"symfony/property-info": "^6.4|^7.0|^8.0",
"symfony/routing": "^6.4|^7.0|^8.0",
"symfony/asset": "^7.4|^8.0",
"symfony/asset-mapper": "^7.4|^8.0",
"symfony/console": "^7.4|^8.0",
"symfony/dependency-injection": "^7.4|^8.0",
"symfony/emoji": "^7.4|^8.0",
"symfony/expression-language": "^7.4|^8.0",
"symfony/finder": "^7.4|^8.0",
"symfony/form": "^7.4.1|^8.0.1",
"symfony/html-sanitizer": "^7.4|^8.0",
"symfony/http-foundation": "^7.4|^8.0",
"symfony/http-kernel": "^7.4|^8.0",
"symfony/intl": "^7.4|^8.0",
"symfony/mime": "^7.4|^8.0",
"symfony/polyfill-intl-icu": "^1.0",
"symfony/property-info": "^7.4|^8.0",
"symfony/routing": "^7.4|^8.0",
"symfony/security-acl": "^2.8|^3.0",
"symfony/security-core": "^6.4|^7.0|^8.0",
"symfony/security-csrf": "^6.4|^7.0|^8.0",
"symfony/security-http": "^6.4|^7.0|^8.0",
"symfony/serializer": "^6.4.3|^7.0.3|^8.0",
"symfony/stopwatch": "^6.4|^7.0|^8.0",
"symfony/translation": "^6.4|^7.0|^8.0",
"symfony/validator": "^6.4|^7.0|^8.0",
"symfony/web-link": "^6.4|^7.0|^8.0",
"symfony/workflow": "^6.4|^7.0|^8.0",
"symfony/yaml": "^6.4|^7.0|^8.0",
"symfony/security-core": "^7.4|^8.0",
"symfony/security-csrf": "^7.4|^8.0",
"symfony/security-http": "^7.4|^8.0",
"symfony/serializer": "^7.4|^8.0",
"symfony/stopwatch": "^7.4|^8.0",
"symfony/translation": "^7.4|^8.0",
"symfony/validator": "^7.4|^8.0",
"symfony/web-link": "^7.4|^8.0",
"symfony/workflow": "^7.4|^8.0",
"symfony/yaml": "^7.4|^8.0",
"twig/cssinliner-extra": "^3",
"twig/inky-extra": "^3",
"twig/markdown-extra": "^3"
@@ -4141,7 +4035,7 @@
"description": "Provides integration for Twig with various Symfony components",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/twig-bridge/tree/v7.4.3"
"source": "https://github.com/symfony/twig-bridge/tree/v8.0.3"
},
"funding": [
{
@@ -4161,7 +4055,7 @@
"type": "tidelift"
}
],
"time": "2025-12-16T08:02:06+00:00"
"time": "2025-12-16T08:10:18+00:00"
},
{
"name": "symfony/twig-bundle",
@@ -4342,26 +4236,25 @@
},
{
"name": "symfony/var-exporter",
"version": "v7.4.0",
"version": "v8.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-exporter.git",
"reference": "03a60f169c79a28513a78c967316fbc8bf17816f"
"reference": "7345f46c251f2eb27c7b3ebdb5bb076b3ffcae04"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/var-exporter/zipball/03a60f169c79a28513a78c967316fbc8bf17816f",
"reference": "03a60f169c79a28513a78c967316fbc8bf17816f",
"url": "https://api.github.com/repos/symfony/var-exporter/zipball/7345f46c251f2eb27c7b3ebdb5bb076b3ffcae04",
"reference": "7345f46c251f2eb27c7b3ebdb5bb076b3ffcae04",
"shasum": ""
},
"require": {
"php": ">=8.2",
"symfony/deprecation-contracts": "^2.5|^3"
"php": ">=8.4"
},
"require-dev": {
"symfony/property-access": "^6.4|^7.0|^8.0",
"symfony/serializer": "^6.4|^7.0|^8.0",
"symfony/var-dumper": "^6.4|^7.0|^8.0"
"symfony/property-access": "^7.4|^8.0",
"symfony/serializer": "^7.4|^8.0",
"symfony/var-dumper": "^7.4|^8.0"
},
"type": "library",
"autoload": {
@@ -4399,7 +4292,7 @@
"serialize"
],
"support": {
"source": "https://github.com/symfony/var-exporter/tree/v7.4.0"
"source": "https://github.com/symfony/var-exporter/tree/v8.0.0"
},
"funding": [
{
@@ -4419,7 +4312,7 @@
"type": "tidelift"
}
],
"time": "2025-09-11T10:15:23+00:00"
"time": "2025-11-05T18:53:00+00:00"
},
{
"name": "twig/cache-extra",
@@ -4788,5 +4681,5 @@
"ext-json": "*"
},
"platform-dev": {},
"plugin-api-version": "2.6.0"
"plugin-api-version": "2.9.0"
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 199 KiB

After

Width:  |  Height:  |  Size: 282 KiB

View File

@@ -6,11 +6,13 @@ namespace Krzysiej\RyobiCrawler\Command;
use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Database\Schema\Blueprint;
use Krzysiej\RyobiCrawler\Models\Country;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use function Symfony\Component\Clock\now;
#[AsCommand(name: 'app:migrate', description: 'Create database and rum migrations')]
class Migrate extends Command
@@ -24,11 +26,10 @@ class Migrate extends Command
public function execute(InputInterface $input, OutputInterface $output): int
{
if (true === $input->hasOption(self::RECREATE_OPTION)) {
if ($input->getOption(self::RECREATE_OPTION)) {
unlink(__DIR__ . '/../../database.sqlite');
//sleep(5);
touch(__DIR__ . '/../../database.sqlite');
}
touch(__DIR__ . '/../../database.sqlite');
$capsule = new Capsule;
$capsule->addConnection([
'driver' => 'sqlite',
@@ -39,6 +40,9 @@ class Migrate extends Command
$this->createProductsTable();
$this->createPricesTable();
$this->createStocksTable();
$this->addColumns();
$this->createCountriesTable();
$this->index();
return Command::SUCCESS;
}
@@ -77,6 +81,51 @@ class Migrate extends Command
}
}
public function createCountriesTable(): void
{
if (!Capsule::schema()->hasTable('countries')) {
Capsule::schema()->create('countries', function (Blueprint $table) {
$table->increments('id');
$table->text('countryName');
$table->text('productsUrl');
$table->text('cultureCode');
$table->text('currency');
$table->text('locale');
$table->timestamps();
});
}
if (Capsule::schema()->hasTable('countries') && !Country::where('countryName', 'Poland')->exists()) {
$id = Capsule::table('countries')->insertGetId(
[
'countryName' => 'Poland',
'productsUrl' => 'https://pl.ryobitools.eu/api/product-listing/get-products',
'cultureCode' => 'pl-PL',
'currency' => 'PLN',
'locale' => 'pl',
'created_at' => now(),
'updated_at' => now(),
]);
}
if (Capsule::schema()->hasTable('countries') && !Country::where('countryName', 'UK')->exists()) {
Capsule::table('countries')->insert([
'countryName' => 'UK',
'productsUrl' => 'https://uk.ryobitools.eu/api/product-listing/get-products',
'cultureCode' => 'en-GB',
'currency' => 'GBP',
'locale' => 'en',
'created_at' => now(),
'updated_at' => now(),
]
);
}
if (!Capsule::schema()->hasColumn('products', 'country_id')) {
Capsule::schema()->table('products', function (Blueprint $table) use ($id) {
$table->foreignId('country_id')->default($id)->references('id')->on('countries');
});
}
}
public function createStocksTable(): void
{
if (!Capsule::schema()->hasTable('stocks')) {
@@ -94,4 +143,57 @@ class Migrate extends Command
});
}
}
public function addColumns(): void
{
if (!Capsule::schema()->hasColumn('products', 'priceCurrent')) {
Capsule::schema()->table('products', function (Blueprint $table) {
$table->float('priceCurrent')->default(0);
});
}
if (!Capsule::schema()->hasColumn('products', 'priceLowest')) {
Capsule::schema()->table('products', function (Blueprint $table) {
$table->float('priceLowest')->default(0);
});
}
if (!Capsule::schema()->hasColumn('products', 'productStandardPrice')) {
Capsule::schema()->table('products', function (Blueprint $table) {
$table->float('productStandardPrice')->default(0);
});
}
if (!Capsule::schema()->hasColumn('products', 'lowestProductPrice30Days')) {
Capsule::schema()->table('products', function (Blueprint $table) {
$table->float('lowestProductPrice30Days')->default(0);
});
}
if (!Capsule::schema()->hasColumn('products', 'lastSeen')) {
Capsule::schema()->table('products', function (Blueprint $table) {
$table->date('lastSeen')->nullable();
});
}
if (!Capsule::schema()->hasColumn('products', 'stock')) {
Capsule::schema()->table('products', function (Blueprint $table) {
$table->integer('stock')->nullable();
});
}
}
public function index(): void
{
if (!count(Capsule::select('SELECT name FROM sqlite_master WHERE type = "index" and name = "products_skuid_country_id_unique"'))) {
Capsule::schema()->table('products', function (Blueprint $table) {
$table->integer('skuID')->unique(false)->change();
$table->unique(['skuID', 'country_id']);
});
}
Capsule::schema()->table('products', function (Blueprint $table) {
$table->foreign('id')->references('product_id')->on('stocks');
});
}
}

View File

@@ -7,6 +7,7 @@ namespace Krzysiej\RyobiCrawler\Command;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Database\Capsule\Manager as Capsule;
use Krzysiej\RyobiCrawler\Models\Country;
use Krzysiej\RyobiCrawler\Models\Price;
use Krzysiej\RyobiCrawler\Models\Product;
use Krzysiej\RyobiCrawler\Models\Stock;
@@ -33,33 +34,61 @@ class ScrapeWebsite extends Command
public function execute(InputInterface $input, OutputInterface $output): int
{
$output->writeln('Scrape products');
$progress = new ProgressBar($output);
$progress->start();
$products = $this->getProducts();
$countries = Country::all();
foreach($countries as $country) {
$output->writeln('Country name: ' . $country->countryName."\n");
$progress->start();
$products = $this->getProducts($country);
$progress->setMaxSteps(count($products));
foreach ($products as $product) {
$this->saveProduct($product, $country);
$progress->advance();
}
$progress->finish();
$output->writeln('');
$output->writeln('Scrape products - DONE');
$output->writeln('');
}
$output->writeln('Update prices');
$products = Product::all();
$progress->setMaxSteps(count($products));
foreach ($products as $product) {
$this->saveProduct($product);
$progress->start();
foreach($products as $product) {
$newestPrice = $product->newestPrice;
$currentStock = $product->currentStock;
$product->priceCurrent = $newestPrice->price;
$product->productStandardPrice = $newestPrice->productStandardPrice;
$product->lowestProductPrice30Days = $newestPrice->lowestProductPrice30Days;
$product->priceLowest = $product->lowestPrice->price;
$product->lastSeen = $newestPrice->created_at->format('Y-m-d');
$product->stock = $currentStock->stock;
$product->save(['timestamps' => false]);
$progress->advance();
}
$progress->finish();
$output->writeln('');
$output->writeln('DONE');
$output->writeln('Update prices - DONE');
$output->writeln('COMMAND - DONE');
return Command::SUCCESS;
}
private function getProducts(): array
private function getProducts(Country $country): array
{
$products = [];
$page = 0;
do {
try {
$res = $this->client->request('POST', 'https://pl.ryobitools.eu/api/product-listing/get-products', [
$res = $this->client->request('POST', $country->productsUrl, [
'form_params' => [
"includePreviousPages" => false,
"pageIndex" => $page,
"pageSize" => 100,
"cultureCode" => "pl-PL",
"cultureCode" => $country->cultureCode,
]
]);
$responseObject = json_decode($res->getBody()->getContents());
@@ -74,21 +103,23 @@ class ScrapeWebsite extends Command
return $products;
}
private function saveProduct(\stdClass $product): void
private function saveProduct(\stdClass $product, Country $country): void
{
/** @var Product $productModel */
$productModel = Product::firstOrNew(['skuID' => $product->skuID]);
$productModel = Product::firstOrNew(['skuID' => $product->skuID, 'country_id' => $country->id]);
$productModel->skuID = $product->skuID;
$productModel->name = $product->name;
$productModel->availableQuantity = $product->availableQuantity;
$productModel->categories = $product->categories;
$productModel->categories = str_replace(['/', ' '], '', $product->categories);
$productModel->image = $product->image;
$productModel->subTitle = $product->subTitle;
$productModel->variantCode = $product->variantCode;
$productModel->modelCode = $product->modelCode;
$productModel->url = $product->url;
$productModel->lastSeen = date("Y-m-d");
$productModel->touch('updated_at');
$productModel->country()->associate($country);
$productModel->save();
$priceExists = $productModel->price()->whereRaw("strftime('%Y-%m-%d', created_at) = ?", [date('Y-m-d')])->exists();

View File

@@ -17,10 +17,9 @@ final class DiscontinuedController extends BaseController
return $this->render('productList.html.twig', ['listType' => 'discontinued']);
}
$products = Product::where('updated_at', '<', now()->format('Y-m-d'))
$products = Product::where('lastSeen', '<', now()->format('Y-m-d'))
->orderByDesc('starred')
->orderByDesc('created_by')
->with(['currentPrice', 'lowestPrice'])
->get();
return $this->render('productList.html.twig', ['products' => $products, 'listType' => 'discontinued']);
}

View File

@@ -14,7 +14,7 @@ final class IndexController extends BaseController
if ($this->cache->getItem('list_all')->isHit()) {
return $this->render('productList.html.twig', ['listType' => 'all']);
}
$products = Product::with(['currentStock', 'price', 'lowestPrice'])
$products = Product::with(['currentStock'])
->orderByDesc('starred')
->orderByDesc('created_by')
->get();

View File

@@ -0,0 +1,29 @@
<?php
namespace Krzysiej\RyobiCrawler\Controller;
use Krzysiej\RyobiCrawler\Models\Product;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use function Symfony\Component\Clock\now;
final class LowestPriceController extends BaseController
{
#[Route('/lowest-price', name: 'app_lowest_price', methods: ['GET'])]
public function __invoke(): Response
{
$listType = 'lowest_price';
if($this->cache->getItem('lowest_price')->isHit()) {
return $this->render('productList.html.twig', ['listType' => $listType]);
}
$products = Product::whereRaw('priceCurrent = priceLowest')
->whereRaw('lastSeen = "'.now()->format('Y-m-d').'"')
->whereRaw('priceCurrent < productStandardPrice')
->orderByDesc('starred')
->orderByDesc('created_by')
->with(['currentPrice', 'lowestPrice'])
->get();
return $this->render('productList.html.twig', ['products' => $products, 'listType' => $listType]);
}
}

View File

@@ -2,7 +2,6 @@
namespace Krzysiej\RyobiCrawler\Controller;
use Illuminate\Database\Eloquent\Builder;
use Krzysiej\RyobiCrawler\Models\Product;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
@@ -17,11 +16,11 @@ final class NewController extends BaseController
if($this->cache->getItem('list_new')->isHit()) {
return $this->render('productList.html.twig', ['listType' => 'new']);
}
$products = Product::where('created_at', '>', now()->modify('-30 days')->format('Y-m-d'))
$date = now()->modify('-30 days')->format('Y-m-d');
$products = Product::where('created_at', '>', $date)
->with(['country', 'stock'])
->orderByDesc('starred')
->orderByDesc('created_by')
->with(['currentPrice', 'lowestPrice'])
->get();
return $this->render('productList.html.twig', ['products' => $products, 'listType' => 'new']);
}

View File

@@ -3,7 +3,6 @@
namespace Krzysiej\RyobiCrawler\Controller;
use Krzysiej\RyobiCrawler\Models\Product;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Twig\Error\LoaderError;
@@ -20,7 +19,7 @@ final class ProductController extends BaseController
#[Route('/product/{productId<\d+>}', name: 'app_product')]
public function __invoke(int $productId): Response
{
if($this->cache->getItem('product'.$productId)->isHit()) {
if ($this->cache->getItem('product' . $productId)->isHit()) {
return $this->render('product.html.twig', ['product' => ['id' => $productId]]);
}
@@ -31,26 +30,34 @@ final class ProductController extends BaseController
if (null === $product) {
throw $this->createNotFoundException('Product not found');
}
$priceList = $product->price()->pluck('price');
$stockList = $product->stock()->pluck('stock');
$priceDates = $product->price()->pluck('created_at')->map(fn($date) => $date->format('Y-m-d'))->toArray();
$stockDates = $product->stock()->pluck('created_at')->map(fn($date) => $date->format('Y-m-d'))->toArray();
$priceList = $product->price()->pluck('price', 'created_at')->mapWithKeys(fn($price, $createdAt) => [explode(' ', $createdAt)[0] => $price])->toArray();
$stockList = $product->stock()->pluck('stock', 'created_at')->mapWithKeys(fn($stock, $createdAt) => [explode(' ', $createdAt)[0] => $stock])->toArray();
return $this->render('product.html.twig', [
'product' => $product,
'price_list' => $this->prepareChartData($priceDates, $priceList),
'stock_list' => $this->prepareChartData($stockDates, $stockList),
'price_dates' => implode("','", $priceDates),
'price_list' => $this->prepareChartData($priceList),
'stock_list' => $this->prepareChartData($stockList),
'price_dates' => implode("','", $this->dateRange(array_key_first($priceList), array_key_last($priceList))),
]);
}
private function prepareChartData($set1, $set2): string
private function prepareChartData($set1): string
{
$data = [];
foreach ($set1 as $key => $value) {
$data[] = ['x' => $value, 'y' => $set2[$key]];
}
$dates = $this->dateRange(array_key_first($set1), array_key_last($set1));
$data = array_map(fn($date) => ['x' => $date, 'y' => $set1[$date] ?? null], $dates);
$stringData = json_encode($data);
return str_replace(['"x"', '"y"'], ['x', 'y'], $stringData);
}
private function dateRange($dateStart, $dateEnd): array
{
$from = new \DateTime($dateStart);
$to = new \DateTime($dateEnd);
$range = [];
for ($date = clone $from; $date < $to; $date->modify('+1 day')) {
$range[] = $date->format('Y-m-d');
}
return $range;
}
}

View File

@@ -2,7 +2,6 @@
namespace Krzysiej\RyobiCrawler\Controller;
use Illuminate\Database\Eloquent\Builder;
use Krzysiej\RyobiCrawler\Models\Product;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
@@ -16,7 +15,7 @@ final class PromosController extends BaseController
return $this->render('productList.html.twig', ['listType' => 'promos']);
}
$products = Product::whereHas('currentPrice', fn(Builder $query) => $query->whereColumn('price', '<', 'productStandardPrice'))
$products = Product::whereRaw('priceCurrent < productStandardPrice')
->orderByDesc('starred')
->orderByDesc('created_by')
->with(['currentPrice', 'lowestPrice'])

View File

@@ -12,7 +12,18 @@ final class StarController extends BaseController
#[Route('/star/{productId<\d+>}', name: 'app_star')]
public function __invoke(int $productId, Request $request): Response
{
$this->cache->deleteItems(['list_all', 'list_promos', 'list_new', 'list_discontinued']);
$referer = $request->headers->get('referer');
if (str_contains($referer, '/category/')) {
preg_match('#/category/(.*)#i', $referer, $matches);
$this->cache->deleteItem('list_category_'.urldecode($matches[1]));
}
if (str_contains($referer, '/search?search=')) {
preg_match('#/search\?search=(.*)#i', $referer, $matches);
$this->cache->deleteItem('list_search_'.urldecode($matches[1]));
}
Product::find($productId)->toggleStarred()->save();
return $this->redirect($request->headers->get('referer'));
return $this->redirect($referer);
}
}

24
src/Models/Country.php Normal file
View File

@@ -0,0 +1,24 @@
<?php
namespace Krzysiej\RyobiCrawler\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
/**
* @property string $countryName
* @property string $productsUrl
* @property string $cultureCode
* @property string $currency
* @property string $locale
*/
class Country extends Model
{
public $timestamps = true;
public function products(): HasMany
{
return $this->hasMany(Product::class);
}
}

View File

@@ -2,8 +2,10 @@
namespace Krzysiej\RyobiCrawler\Models;
use Carbon\Traits\Date;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
@@ -20,11 +22,22 @@ use function Symfony\Component\Clock\now;
* @property string $modelCode
* @property string $url
* @property int $starred
* @property float $priceCurrent
* @property float $priceLowest
* @property float $productStandardPrice
* @property float $lowestProductPrice30Days
* @property Date $lastSeen
* @property integer $stock
*/
class Product extends Model
{
public $timestamps = true;
public $fillable = ['skuID'];
public $fillable = ['skuID', 'country_id'];
public function country(): BelongsTo
{
return $this->belongsTo(Country::class);
}
public function price(): HasMany
{
@@ -45,6 +58,10 @@ class Product extends Model
{
return $this->hasOne(Price::class)->ofMany('price', 'MIN');
}
public function newestPrice(): HasOne
{
return $this->hasOne(Price::class)->latest();
}
public function stock(): HasMany
{
@@ -53,9 +70,7 @@ class Product extends Model
public function currentStock(): HasOne
{
return $this->stock()->one()->ofMany()->withDefault(function (Stock $stock) {
$stock->stock = 0;
});
return $this->stock()->one()->ofMany()->withDefault(fn (Stock $stock) => $stock->stock = 0);
}
public function toggleStarred(): self
@@ -75,7 +90,7 @@ class Product extends Model
public function isDiscontinued(): bool
{
return $this->updated_at->format('Y-m-d') < now()->format('Y-m-d');
return $this->lastSeen < now()->format('Y-m-d');
}
public function isNew(): bool
{

View File

@@ -22,6 +22,7 @@ class AppExtension extends AbstractExtension
new TwigFunction('allCount', [$this, 'allCount']),
new TwigFunction('newCount', [$this, 'newCount']),
new TwigFunction('discontinuedCount', [$this, 'discontinuedCount']),
new TwigFunction('lowestPriceCount', [$this, 'lowestPriceCount']),
];
}
@@ -31,6 +32,7 @@ class AppExtension extends AbstractExtension
new TwigFilter('findByCreatedAtDate', [$this, 'findByCreatedAtDate']),
];
}
public function allCount(): int
{
return Product::count();
@@ -38,7 +40,7 @@ class AppExtension extends AbstractExtension
public function promosCount(): int
{
return Product::whereHas('currentPrice', fn(Builder $query) => $query->whereColumn('price', '<', 'productStandardPrice'))->count();
return Product::whereRaw('priceCurrent < productStandardPrice')->count();
}
public function newCount(): int
@@ -48,7 +50,15 @@ class AppExtension extends AbstractExtension
public function discontinuedCount(): int
{
return Product::where('updated_at', '<', now()->format('Y-m-d'))->count();
return Product::where('lastSeen', '<>', now()->format('Y-m-d'))->count();
}
public function lowestPriceCount(): int
{
return Product::whereRaw('priceCurrent = priceLowest')
->whereRaw('lastSeen = "'.now()->format('Y-m-d').'"')
->whereRaw('priceCurrent < productStandardPrice')
->count();
}
public function findByCreatedAtDate(Collection $items, string $date): Stock|Price|null

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

7
templates/js/bootstrap.bundle.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -10,7 +10,7 @@
<td><img src='{{ product.image }}&width=150' class='border rounded p-1' alt='{{ product.name }}'/></td>
<td>
<a href='{{ path('app_product', {'productId': product.id}) }}' class="text-decoration-none">{{ product.name }}</a>
<span class="badge text-bg-light">{{ product.subTitle }}</span>
<span class="badge text-bg-light"><a href="{{ path('app_search', {'search': product.subTitle}) }}" class="link-underline link-underline-opacity-0 link-dark">{{ product.subTitle }}</a></span>
</td>
<td>
<nav aria-label="breadcrumb" style="--bs-breadcrumb-divider: '>';">
@@ -42,13 +42,14 @@
<th>Stock</th>
</tr>
</thead>
{% set stock = product.stock().get() %}
{% for price in product.price %}
<tr>
<td>{{ price.price | format_currency('PLN', {}, 'pl') }}</td>
<td>{{ price.lowestProductPrice30Days | format_currency('PLN', {}, 'pl') }}</td>
<td>{{ price.productStandardPrice | format_currency('PLN', {}, 'pl') }}</td>
<td>{{ price.price | format_currency(product.country.currency, {}, product.country.locale) }}</td>
<td>{{ price.lowestProductPrice30Days | format_currency(product.country.currency, {}, product.country.locale) }}</td>
<td>{{ price.productStandardPrice | format_currency(product.country.currency, {}, product.country.locale) }}</td>
<td>{{ price.created_at }}</td>
<td>{{ (product.stock | findByCreatedAtDate(price.created_at | slice(0,10))).stock ?? '' }}</td>
<td>{{ (stock | findByCreatedAtDate(price.created_at | slice(0,10))).stock ?? '' }}</td>
</tr>
{% endfor %}
</table>
@@ -67,7 +68,7 @@
labels: ['{{ price_dates|raw }}'],
datasets: [
{
label: 'Price (PLN)',
label: 'Price ({{ product.country.currency }})',
data: {{ price_list|raw }},
yAxisID: 'yPrice',
tension: 0.1,
@@ -83,6 +84,7 @@
]
},
options: {
spanGaps: false,
responsive: true,
animation: false,
scales: {
@@ -98,7 +100,7 @@
beginAtZero: true,
title: {
display: true,
text: 'Price (PLN)'
text: 'Price ({{ product.country.currency }})'
},
grid: {
drawOnChartArea: false

View File

@@ -23,18 +23,18 @@
<td class="align-middle" style="width: 120px;"><img src='{{ product.image }}&width=70' class='img-thumbnail' alt='{{ product.name }}'/></td>
<td class="align-middle">
<a href='{{ path('app_product', {'productId': product.id}) }}' class="text-decoration-none">{{ product.name }}</a>
{% if product.currentStock.stock > 0 %}
<span class="badge text-bg-light">stock: {{ product.currentStock.stock }}</span>
{% if product.stock > 0 %}
<span class="badge text-bg-light">stock: {{ product.stock }}</span>
{% else %}
<span class="badge text-bg-warning">out of stock</span>
{% endif %}
{% if product.isDiscontinued() %}
<span class="badge text-bg-secondary" data-bs-toggle="tooltip" data-bs-title="Last update: {{ product.updated_at }}">is discontinued</span>
<span class="badge text-bg-secondary" data-bs-toggle="tooltip" data-bs-title="Last update: {{ product.lastSeen }}">is discontinued</span>
{% endif %}
{% if product.isNew() %}
<span class="badge text-bg-success">is new</span>
{% endif %}
<span class="badge text-bg-light">{{ product.subTitle }}</span>
<span class="badge text-bg-light"><a href="{{ path('app_search', {'search': product.subTitle}) }}" class="link-underline link-underline-opacity-0 link-dark">{{ product.subTitle }}</a></span>
</td>
<td class="align-middle">
<nav aria-label="breadcrumb" style="--bs-breadcrumb-divider: '>';" >
@@ -46,13 +46,19 @@
</nav>
</td>
<td class="align-middle"><a href='https://pl.ryobitools.eu/{{ product.url }}'>link</a></td>
<td class="align-middle text-end">{% if product.lowestPrice.price != product.price.last.price %}{{ product.lowestPrice.price | format_currency('PLN', {}, 'pl') }}{% endif %}</td>
<td class="align-middle text-end">{{ product.price.last.price | format_currency('PLN', {}, 'pl') }}</td>
<td class="align-middle text-end">
{% if product.isDiscontinued() or product.priceCurrent == product.productStandardPrice %}
{{ product.priceLowest | format_currency(product.country.currency, {}, product.country.locale) }}
{% else %}
{% if product.priceLowest != product.priceCurrent %}{{ product.priceLowest | format_currency(product.country.currency, {}, product.country.locale) }}{%else%}<span class="badge text-bg-info">now lowest</span>{% endif %}</td>
{% endif %}
<td class="align-middle text-end">{{ product.priceCurrent | format_currency(product.country.currency, {}, product.country.locale) }}</td>
<td class="align-middle">
<div class="d-flex flex-row">
{% if product.price.last.price != product.price.last.productStandardPrice %}<span
class="badge text-bg-warning text-decoration-line-through flex-fill">{{ product.price.last.productStandardPrice | format_currency('PLN', {}, 'pl') }}</span> <span
class="badge text-bg-success flex-fill">{{ ((1 - product.price.last.price / product.price.last.productStandardPrice)*100)|number_format(0) }}%</span>
{% if product.priceCurrent != product.productStandardPrice %}<span
class="badge text-bg-warning text-decoration-line-through flex-fill">{{ product.productStandardPrice | format_currency(product.country.currency, {}, product.country.locale) }}</span> <span
class="badge text-bg-success flex-fill">{{ ((1 - product.priceCurrent / product.productStandardPrice)*100)|number_format(0) }}%</span>
{% endif %}
</div>
</td>

View File

@@ -18,13 +18,16 @@
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
{% cache "menu_count" %}
{% cache "menu_count" ~ listType|default('') %}
<li class="nav-item">
<a class="nav-link {% if app.request.pathinfo == path('app_home') %}active shadow-sm bg-body rounded{% endif %}" aria-current="page" href="{{ path('app_home') }}">All products <span class="badge text-bg-secondary">{{ allCount() }}</span></a>
</li>
<li class="nav-item">
<a class="nav-link {% if app.request.pathinfo == path('app_promos') %}active shadow-sm bg-body rounded{% endif %}" aria-current="page" href="{{ path('app_promos') }}">Promos <span class="badge text-bg-secondary">{{ promosCount() }}</span></a>
</li>
<li class="nav-item">
<a class="nav-link {% if app.request.pathinfo == path('app_lowest_price') %}active shadow-sm bg-body rounded{% endif %}" aria-current="page" href="{{ path('app_lowest_price') }}">Lowest price <span class="badge text-bg-secondary">{{ lowestPriceCount() }}</span></a>
</li>
<li class="nav-item">
<a class="nav-link {% if app.request.pathinfo == path('app_new') %}active shadow-sm bg-body rounded{% endif %}" aria-current="page" href="{{ path('app_new') }}">New in last 30 days <span class="badge text-bg-secondary">{{ newCount() }}</span></a>
</li>
@@ -44,8 +47,7 @@
</nav>
{% block content %}{% endblock %}
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
<script src="/templates/js/bootstrap.bundle.min.js"></script>
</body>
</html>