Compare commits
49 Commits
0168290340
...
feature/or
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2e4c79c87a | ||
| 6246ad8692 | |||
|
|
d18abc6159 | ||
| 5832ac583f | |||
|
|
8f87a6bbf0 | ||
| ef1b7b8a9e | |||
| b0134accfa | |||
|
|
ae0f9b3be7 | ||
|
|
5c2777999a | ||
|
|
71279025ae | ||
| f334ba0232 | |||
|
|
81f9c863c7 | ||
| 7eb7bf3eb2 | |||
|
|
ac1f0af5ae | ||
| 35aea9dd7e | |||
|
|
62239bd052 | ||
|
|
c947e470af | ||
|
|
8eeba225ed | ||
| 22e59a2438 | |||
|
|
585f1336d2 | ||
|
|
9b6bcd22be | ||
| a26ad401df | |||
|
|
3705990be1 | ||
| c65f0fdb3e | |||
| d6bcffc3e1 | |||
| faf9c8a480 | |||
| 14104f61a4 | |||
| 44254ed12a | |||
|
|
d9740a86d0 | ||
|
|
bd62a23854 | ||
| 2dc4dc778d | |||
|
|
85e32554ef | ||
| ebd48cfbf6 | |||
|
|
369bacc38c | ||
| 277257fda2 | |||
|
|
0e5d76313f | ||
| 54488f0b19 | |||
|
|
a6b108cb74 | ||
|
|
0db4bacff4 | ||
| 37680b0c91 | |||
|
|
0e8c312f5e | ||
| 685bff3ffc | |||
|
|
11284e59ea | ||
| 50305d5b5d | |||
|
|
f963dcd4c8 | ||
|
|
48ee68f71a | ||
| f1c0ec6b3a | |||
|
|
c280abe484 | ||
|
|
7053716924 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@
|
|||||||
.idea
|
.idea
|
||||||
database.sqlite
|
database.sqlite
|
||||||
var/cache/
|
var/cache/
|
||||||
|
.env.local
|
||||||
@@ -1,13 +1,15 @@
|
|||||||
FROM php:8.3-cli
|
FROM php:8.3-cli
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
ENV PHP_MEMORY_LIMIT=512M
|
||||||
|
RUN echo "memory_limit=512M" > /usr/local/etc/php/conf.d/memory-limit.ini
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
git \
|
git \
|
||||||
unzip \
|
unzip \
|
||||||
|
libicu-dev \
|
||||||
libzip-dev
|
libzip-dev
|
||||||
|
|
||||||
RUN docker-php-ext-install zip
|
RUN docker-php-ext-install zip intl
|
||||||
|
|
||||||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,8 @@
|
|||||||
|
|
||||||
1. Cd into project directory
|
1. Cd into project directory
|
||||||
2. Run `git pull`
|
2. Run `git pull`
|
||||||
3. Start and build image in one go with command: `docker compose up -d --build --force-recreate`
|
3. Refresh cache on production by removing cache directory: `rm -rf var/cache`
|
||||||
|
4. Start and build image in one go with command: `docker compose up -d --build --force-recreate`
|
||||||
|
|
||||||
## Running Cron
|
## Running Cron
|
||||||
|
|
||||||
|
|||||||
3
bin/cli
Executable file
3
bin/cli
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
[ -z "$1" ] && echo "Please specify a CLI command (ex. ls)" && exit
|
||||||
|
docker compose exec php-app "$@"
|
||||||
5
bin/update
Executable file
5
bin/update
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
echo "Updating project"
|
||||||
|
git pull origin master
|
||||||
|
bin/cli rm -rf var/cache
|
||||||
|
echo "Project updated"
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"require": {
|
"require": {
|
||||||
"guzzlehttp/guzzle": "^7.0",
|
"guzzlehttp/guzzle": "^7.0",
|
||||||
"symfony/var-dumper": "^7.0",
|
|
||||||
"illuminate/database": "11.26.0.0",
|
"illuminate/database": "11.26.0.0",
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"symfony/console": "^7.0",
|
"symfony/console": "^7.0",
|
||||||
@@ -9,11 +8,17 @@
|
|||||||
"laravel/serializable-closure": "^1.3",
|
"laravel/serializable-closure": "^1.3",
|
||||||
"symfony/http-kernel": "^7.1",
|
"symfony/http-kernel": "^7.1",
|
||||||
"symfony/framework-bundle": "^7.1",
|
"symfony/framework-bundle": "^7.1",
|
||||||
"symfony/twig-bundle": "^7.1"
|
"symfony/twig-bundle": "^7.1",
|
||||||
|
"symfony/dotenv": "^7.1",
|
||||||
|
"twig/intl-extra": "^3.13",
|
||||||
|
"twig/extra-bundle": "^3.13"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Krzysiej\\RyobiCrawler\\": "src/"
|
"Krzysiej\\RyobiCrawler\\": "src/"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"symfony/var-dumper": "^7.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
312
composer.lock
generated
312
composer.lock
generated
@@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "9c0c7b968c4acc975c2de9bd993c6645",
|
"content-hash": "a6920081bf40809334b8dda2da16752d",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "brick/math",
|
"name": "brick/math",
|
||||||
@@ -2176,6 +2176,80 @@
|
|||||||
],
|
],
|
||||||
"time": "2024-04-18T09:32:20+00:00"
|
"time": "2024-04-18T09:32:20+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "symfony/dotenv",
|
||||||
|
"version": "v7.1.5",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/symfony/dotenv.git",
|
||||||
|
"reference": "6d966200b399fa59759286f3fc7c919f0677c449"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/symfony/dotenv/zipball/6d966200b399fa59759286f3fc7c919f0677c449",
|
||||||
|
"reference": "6d966200b399fa59759286f3fc7c919f0677c449",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=8.2"
|
||||||
|
},
|
||||||
|
"conflict": {
|
||||||
|
"symfony/console": "<6.4",
|
||||||
|
"symfony/process": "<6.4"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"symfony/console": "^6.4|^7.0",
|
||||||
|
"symfony/process": "^6.4|^7.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Symfony\\Component\\Dotenv\\": ""
|
||||||
|
},
|
||||||
|
"exclude-from-classmap": [
|
||||||
|
"/Tests/"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Fabien Potencier",
|
||||||
|
"email": "fabien@symfony.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Symfony Community",
|
||||||
|
"homepage": "https://symfony.com/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Registers environment variables from a .env file",
|
||||||
|
"homepage": "https://symfony.com",
|
||||||
|
"keywords": [
|
||||||
|
"dotenv",
|
||||||
|
"env",
|
||||||
|
"environment"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/symfony/dotenv/tree/v7.1.5"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://symfony.com/sponsor",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/fabpot",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2024-09-17T09:16:35+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/error-handler",
|
"name": "symfony/error-handler",
|
||||||
"version": "v7.1.3",
|
"version": "v7.1.3",
|
||||||
@@ -2875,6 +2949,92 @@
|
|||||||
],
|
],
|
||||||
"time": "2024-09-21T06:09:21+00:00"
|
"time": "2024-09-21T06:09:21+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "symfony/intl",
|
||||||
|
"version": "v7.1.8",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/symfony/intl.git",
|
||||||
|
"reference": "e56b243fc0afa5a12bd11dace4002ada5a7d99f8"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/symfony/intl/zipball/e56b243fc0afa5a12bd11dace4002ada5a7d99f8",
|
||||||
|
"reference": "e56b243fc0afa5a12bd11dace4002ada5a7d99f8",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=8.2",
|
||||||
|
"symfony/deprecation-contracts": "^2.5|^3"
|
||||||
|
},
|
||||||
|
"conflict": {
|
||||||
|
"symfony/string": "<7.1"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"symfony/filesystem": "^6.4|^7.0",
|
||||||
|
"symfony/var-exporter": "^6.4|^7.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Symfony\\Component\\Intl\\": ""
|
||||||
|
},
|
||||||
|
"exclude-from-classmap": [
|
||||||
|
"/Tests/",
|
||||||
|
"/Resources/data/"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Bernhard Schussek",
|
||||||
|
"email": "bschussek@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Eriksen Costa",
|
||||||
|
"email": "eriksen.costa@infranology.com.br"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Igor Wiedler",
|
||||||
|
"email": "igor@wiedler.ch"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Symfony Community",
|
||||||
|
"homepage": "https://symfony.com/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Provides access to the localization data of the ICU library",
|
||||||
|
"homepage": "https://symfony.com",
|
||||||
|
"keywords": [
|
||||||
|
"i18n",
|
||||||
|
"icu",
|
||||||
|
"internationalization",
|
||||||
|
"intl",
|
||||||
|
"l10n",
|
||||||
|
"localization"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/symfony/intl/tree/v7.1.8"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://symfony.com/sponsor",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/fabpot",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2024-11-08T15:46:42+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/polyfill-ctype",
|
"name": "symfony/polyfill-ctype",
|
||||||
"version": "v1.31.0",
|
"version": "v1.31.0",
|
||||||
@@ -3963,16 +4123,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/var-dumper",
|
"name": "symfony/var-dumper",
|
||||||
"version": "v7.1.5",
|
"version": "v7.1.8",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/var-dumper.git",
|
"url": "https://github.com/symfony/var-dumper.git",
|
||||||
"reference": "e20e03889539fd4e4211e14d2179226c513c010d"
|
"reference": "7bb01a47b1b00428d32b5e7b4d3b2d1aa58d3db8"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/e20e03889539fd4e4211e14d2179226c513c010d",
|
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/7bb01a47b1b00428d32b5e7b4d3b2d1aa58d3db8",
|
||||||
"reference": "e20e03889539fd4e4211e14d2179226c513c010d",
|
"reference": "7bb01a47b1b00428d32b5e7b4d3b2d1aa58d3db8",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -4026,7 +4186,7 @@
|
|||||||
"dump"
|
"dump"
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"source": "https://github.com/symfony/var-dumper/tree/v7.1.5"
|
"source": "https://github.com/symfony/var-dumper/tree/v7.1.8"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -4042,7 +4202,7 @@
|
|||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2024-09-16T10:07:02+00:00"
|
"time": "2024-11-08T15:46:42+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/var-exporter",
|
"name": "symfony/var-exporter",
|
||||||
@@ -4120,6 +4280,144 @@
|
|||||||
],
|
],
|
||||||
"time": "2024-06-28T08:00:31+00:00"
|
"time": "2024-06-28T08:00:31+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "twig/extra-bundle",
|
||||||
|
"version": "v3.13.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/twigphp/twig-extra-bundle.git",
|
||||||
|
"reference": "21a9a7aa9f79d4493bb6fed4eb2794339f9551f5"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/twigphp/twig-extra-bundle/zipball/21a9a7aa9f79d4493bb6fed4eb2794339f9551f5",
|
||||||
|
"reference": "21a9a7aa9f79d4493bb6fed4eb2794339f9551f5",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=8.0.2",
|
||||||
|
"symfony/framework-bundle": "^5.4|^6.4|^7.0",
|
||||||
|
"symfony/twig-bundle": "^5.4|^6.4|^7.0",
|
||||||
|
"twig/twig": "^3.0|^4.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"league/commonmark": "^1.0|^2.0",
|
||||||
|
"symfony/phpunit-bridge": "^6.4|^7.0",
|
||||||
|
"twig/cache-extra": "^3.0",
|
||||||
|
"twig/cssinliner-extra": "^3.0",
|
||||||
|
"twig/html-extra": "^3.0",
|
||||||
|
"twig/inky-extra": "^3.0",
|
||||||
|
"twig/intl-extra": "^3.0",
|
||||||
|
"twig/markdown-extra": "^3.0",
|
||||||
|
"twig/string-extra": "^3.0"
|
||||||
|
},
|
||||||
|
"type": "symfony-bundle",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Twig\\Extra\\TwigExtraBundle\\": ""
|
||||||
|
},
|
||||||
|
"exclude-from-classmap": [
|
||||||
|
"/Tests/"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Fabien Potencier",
|
||||||
|
"email": "fabien@symfony.com",
|
||||||
|
"homepage": "http://fabien.potencier.org",
|
||||||
|
"role": "Lead Developer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "A Symfony bundle for extra Twig extensions",
|
||||||
|
"homepage": "https://twig.symfony.com",
|
||||||
|
"keywords": [
|
||||||
|
"bundle",
|
||||||
|
"extra",
|
||||||
|
"twig"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/twigphp/twig-extra-bundle/tree/v3.13.0"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/fabpot",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/twig/twig",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2024-09-01T20:39:12+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "twig/intl-extra",
|
||||||
|
"version": "v3.13.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/twigphp/intl-extra.git",
|
||||||
|
"reference": "1b8d78c5db08bdc61015fd55009d2e84b3aa7e38"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/twigphp/intl-extra/zipball/1b8d78c5db08bdc61015fd55009d2e84b3aa7e38",
|
||||||
|
"reference": "1b8d78c5db08bdc61015fd55009d2e84b3aa7e38",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=8.0.2",
|
||||||
|
"symfony/intl": "^5.4|^6.4|^7.0",
|
||||||
|
"twig/twig": "^3.13|^4.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"symfony/phpunit-bridge": "^6.4|^7.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Twig\\Extra\\Intl\\": ""
|
||||||
|
},
|
||||||
|
"exclude-from-classmap": [
|
||||||
|
"/Tests/"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Fabien Potencier",
|
||||||
|
"email": "fabien@symfony.com",
|
||||||
|
"homepage": "http://fabien.potencier.org",
|
||||||
|
"role": "Lead Developer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "A Twig extension for Intl",
|
||||||
|
"homepage": "https://twig.symfony.com",
|
||||||
|
"keywords": [
|
||||||
|
"intl",
|
||||||
|
"twig"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/twigphp/intl-extra/tree/v3.13.0"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/fabpot",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/twig/twig",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2024-09-03T13:08:40+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "twig/twig",
|
"name": "twig/twig",
|
||||||
"version": "v3.14.0",
|
"version": "v3.14.0",
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Krzysiej\RyobiCrawler\Twig\AppExtension;
|
||||||
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
|
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
|
||||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||||
|
use Symfony\Component\Dotenv\Dotenv;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
|
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
|
||||||
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
|
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
|
||||||
@@ -16,7 +18,8 @@ class Kernel extends BaseKernel
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
|
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
|
||||||
new Symfony\Bundle\TwigBundle\TwigBundle()
|
new Symfony\Bundle\TwigBundle\TwigBundle(),
|
||||||
|
new Twig\Extra\TwigExtraBundle\TwigExtraBundle(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,6 +33,7 @@ class Kernel extends BaseKernel
|
|||||||
->autowire()
|
->autowire()
|
||||||
->autoconfigure()
|
->autoconfigure()
|
||||||
;
|
;
|
||||||
|
$container->services()->set(AppExtension::class)->tag('twig.extension');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configureRoutes(RoutingConfigurator $routes): void
|
protected function configureRoutes(RoutingConfigurator $routes): void
|
||||||
@@ -37,8 +41,9 @@ class Kernel extends BaseKernel
|
|||||||
$routes->import(__DIR__.'/src/Controller/', 'attribute');
|
$routes->import(__DIR__.'/src/Controller/', 'attribute');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
(new Dotenv())->bootEnv(__DIR__.'/.env');
|
||||||
|
|
||||||
$kernel = new Kernel('prod', false);
|
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
|
||||||
$request = Request::createFromGlobals();
|
$request = Request::createFromGlobals();
|
||||||
$response = $kernel->handle($request);
|
$response = $kernel->handle($request);
|
||||||
$response->send();
|
$response->send();
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
include_once 'vendor/autoload.php';
|
|
||||||
|
|
||||||
use Krzysiej\RyobiCrawler\Controller\CategoryController;
|
|
||||||
use Krzysiej\RyobiCrawler\Controller\IndexController;
|
|
||||||
use Krzysiej\RyobiCrawler\Controller\ProductController;
|
|
||||||
use Krzysiej\RyobiCrawler\Controller\PromosController;
|
|
||||||
use Krzysiej\RyobiCrawler\Controller\SearchController;
|
|
||||||
use Krzysiej\RyobiCrawler\Controller\StarController;
|
|
||||||
use Symfony\Component\Routing\Matcher\UrlMatcher;
|
|
||||||
use Symfony\Component\Routing\RequestContext;
|
|
||||||
use Symfony\Component\Routing\Route;
|
|
||||||
use Symfony\Component\Routing\RouteCollection;
|
|
||||||
|
|
||||||
if (!file_exists('database.sqlite')) {
|
|
||||||
exit('Database file <code>database.sqlite</code> missing. Run docker compose <blockquote>docker compose exec php-app php index.php app:migrate</blockquote> to create it.');
|
|
||||||
}
|
|
||||||
$productRoute = new Route('/product/{product_id<\d+>}', ['_controller' => ProductController::class]);
|
|
||||||
$searchRoute = new Route('/?search={search_term}', ['_controller' => SearchController::class]);
|
|
||||||
$categoryRoute = new Route('/category/{category_name}', ['_controller' => CategoryController::class]);
|
|
||||||
$starRoute = new Route('/star/{product_id}', ['_controller' => StarController::class]);
|
|
||||||
$promosRoute = new Route('/promos', ['_controller' => PromosController::class]);
|
|
||||||
$indexRoute = new Route('/', ['_controller' => IndexController::class]);
|
|
||||||
$routes = new RouteCollection();
|
|
||||||
|
|
||||||
$routes->add('product_show', $productRoute);
|
|
||||||
$routes->add('search_show', $searchRoute);
|
|
||||||
$routes->add('category_show', $categoryRoute);
|
|
||||||
$routes->add('start_show', $starRoute);
|
|
||||||
$routes->add('promos_show', $promosRoute);
|
|
||||||
$routes->add('index_show', $indexRoute);
|
|
||||||
|
|
||||||
$context = new RequestContext();
|
|
||||||
$matcher = new UrlMatcher($routes, $context);
|
|
||||||
try {
|
|
||||||
$parameters = $matcher->match($_SERVER['REQUEST_URI']);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
die($e->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
match ($parameters['_controller']) {
|
|
||||||
SearchController::class => (new $parameters['_controller']())($parameters['search_term']),
|
|
||||||
CategoryController::class => (new $parameters['_controller']())($parameters['category_name']),
|
|
||||||
ProductController::class, StarController::class => (new $parameters['_controller']())($parameters['product_id']),
|
|
||||||
PromosController::class, IndexController::class => (new $parameters['_controller']())(),
|
|
||||||
default => throw new Exception('Route not found')
|
|
||||||
};
|
|
||||||
BIN
screenshot1.png
BIN
screenshot1.png
Binary file not shown.
|
Before Width: | Height: | Size: 133 KiB After Width: | Height: | Size: 199 KiB |
@@ -51,7 +51,6 @@ class Migrate extends Command
|
|||||||
$table->string('name');
|
$table->string('name');
|
||||||
$table->integer('skuID')->unique();
|
$table->integer('skuID')->unique();
|
||||||
$table->integer('availableQuantity');
|
$table->integer('availableQuantity');
|
||||||
$table->integer('stock');
|
|
||||||
$table->json('categories');
|
$table->json('categories');
|
||||||
$table->string('image');
|
$table->string('image');
|
||||||
$table->string('subTitle');
|
$table->string('subTitle');
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ class ScrapeWebsite extends Command
|
|||||||
$products = $this->getProducts();
|
$products = $this->getProducts();
|
||||||
$progress->setMaxSteps(count($products));
|
$progress->setMaxSteps(count($products));
|
||||||
foreach ($products as $product) {
|
foreach ($products as $product) {
|
||||||
//dd($product);
|
|
||||||
$this->saveProduct($product);
|
$this->saveProduct($product);
|
||||||
$progress->advance();
|
$progress->advance();
|
||||||
}
|
}
|
||||||
@@ -69,7 +68,7 @@ class ScrapeWebsite extends Command
|
|||||||
$products = array_merge($products, $responseObject->products);
|
$products = array_merge($products, $responseObject->products);
|
||||||
$page++;
|
$page++;
|
||||||
$canLoadMore = $responseObject->canLoadMore;
|
$canLoadMore = $responseObject->canLoadMore;
|
||||||
} catch (GuzzleException $e) {
|
} catch (GuzzleException) {
|
||||||
return $products;
|
return $products;
|
||||||
}
|
}
|
||||||
} while ($canLoadMore);
|
} while ($canLoadMore);
|
||||||
@@ -81,18 +80,17 @@ class ScrapeWebsite extends Command
|
|||||||
{
|
{
|
||||||
/** @var Product $productModel */
|
/** @var Product $productModel */
|
||||||
$productModel = Product::firstOrNew(['skuID' => $product->skuID]);
|
$productModel = Product::firstOrNew(['skuID' => $product->skuID]);
|
||||||
//dd($productModel);
|
|
||||||
|
|
||||||
$productModel->skuID = $product->skuID;
|
$productModel->skuID = $product->skuID;
|
||||||
$productModel->name = $product->name;
|
$productModel->name = $product->name;
|
||||||
$productModel->availableQuantity = $product->availableQuantity;
|
$productModel->availableQuantity = $product->availableQuantity;
|
||||||
$productModel->stock = $product->stock;
|
|
||||||
$productModel->categories = $product->categories;
|
$productModel->categories = $product->categories;
|
||||||
$productModel->image = $product->image;
|
$productModel->image = $product->image;
|
||||||
$productModel->subTitle = $product->subTitle;
|
$productModel->subTitle = $product->subTitle;
|
||||||
$productModel->variantCode = $product->variantCode;
|
$productModel->variantCode = $product->variantCode;
|
||||||
$productModel->modelCode = $product->modelCode;
|
$productModel->modelCode = $product->modelCode;
|
||||||
$productModel->url = $product->url;
|
$productModel->url = $product->url;
|
||||||
|
$productModel->touch('updated_at');
|
||||||
$productModel->save();
|
$productModel->save();
|
||||||
$priceExists = $productModel->price()->whereRaw("strftime('%Y-%m-%d', created_at) = ?", [date('Y-m-d')])->exists();
|
$priceExists = $productModel->price()->whereRaw("strftime('%Y-%m-%d', created_at) = ?", [date('Y-m-d')])->exists();
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace Krzysiej\RyobiCrawler\Controller;
|
namespace Krzysiej\RyobiCrawler\Controller;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||||
|
|
||||||
@@ -17,4 +19,19 @@ class BaseController extends AbstractController
|
|||||||
$capsule->setAsGlobal();
|
$capsule->setAsGlobal();
|
||||||
$capsule->bootEloquent();
|
$capsule->bootEloquent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function handleOrderProducts(Builder $builder, Request $request): Builder
|
||||||
|
{
|
||||||
|
$builder->orderByDesc('starred')->orderByDesc('created_by');
|
||||||
|
if ($request->query->get('order')) {
|
||||||
|
$orderField = $request->query->get('order');
|
||||||
|
$direction = 'desc';
|
||||||
|
if (str_starts_with($orderField, '-')) {
|
||||||
|
$direction = 'asc';
|
||||||
|
}
|
||||||
|
$builder->orderBy($request->query->get('order'), $direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $builder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ final class CategoryController extends BaseController
|
|||||||
{
|
{
|
||||||
$products = Product::with('price')
|
$products = Product::with('price')
|
||||||
->selectRaw('products.*')
|
->selectRaw('products.*')
|
||||||
|
->distinct('products.id')
|
||||||
->fromRaw('products, json_each(products.categories)')
|
->fromRaw('products, json_each(products.categories)')
|
||||||
->whereRaw('json_each.value = ?', [$category])
|
->whereRaw('json_each.value = ?', [$category])
|
||||||
->orderByDesc('starred')
|
->orderByDesc('starred')
|
||||||
|
|||||||
24
src/Controller/DiscontinuedController.php
Normal file
24
src/Controller/DiscontinuedController.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?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 DiscontinuedController extends BaseController
|
||||||
|
{
|
||||||
|
#[Route('/discontinued', name: 'app_discontinued')]
|
||||||
|
public function __invoke(): Response
|
||||||
|
{
|
||||||
|
|
||||||
|
$products = Product::where('updated_at', '<', now()->format('Y-m-d'))
|
||||||
|
->orderByDesc('starred')
|
||||||
|
->orderByDesc('created_by')
|
||||||
|
->with(['currentPrice'])
|
||||||
|
->get();
|
||||||
|
return $this->render('productList.html.twig', ['products' => $products]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,15 +3,17 @@
|
|||||||
namespace Krzysiej\RyobiCrawler\Controller;
|
namespace Krzysiej\RyobiCrawler\Controller;
|
||||||
|
|
||||||
use Krzysiej\RyobiCrawler\Models\Product;
|
use Krzysiej\RyobiCrawler\Models\Product;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
|
||||||
final class IndexController extends BaseController
|
final class IndexController extends BaseController
|
||||||
{
|
{
|
||||||
#[Route('/', name: 'app_home')]
|
#[Route('/', name: 'app_home')]
|
||||||
public function __invoke(): Response
|
public function __invoke(Request $request): Response
|
||||||
{
|
{
|
||||||
$products = Product::with('price')->orderByDesc('starred')->orderByDesc('created_by')->get();
|
$products = Product::with(['currentStock', 'price', 'currentPrice']);
|
||||||
|
$products = $this->handleOrderProducts($products, $request)->get();
|
||||||
return $this->render('productList.html.twig', ['products' => $products]);
|
return $this->render('productList.html.twig', ['products' => $products]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
25
src/Controller/NewController.php
Normal file
25
src/Controller/NewController.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
use function Symfony\Component\Clock\now;
|
||||||
|
|
||||||
|
final class NewController extends BaseController
|
||||||
|
{
|
||||||
|
#[Route('/new', name: 'app_new')]
|
||||||
|
public function __invoke(): Response
|
||||||
|
{
|
||||||
|
$products = Product::where('created_at', '>', now()->modify('-30 days')->format('Y-m-d'))
|
||||||
|
->orderByDesc('starred')
|
||||||
|
->orderByDesc('name')
|
||||||
|
->orderByDesc('created_by')
|
||||||
|
->with(['currentPrice'])
|
||||||
|
->get();
|
||||||
|
return $this->render('productList.html.twig', ['products' => $products]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace Krzysiej\RyobiCrawler\Controller;
|
namespace Krzysiej\RyobiCrawler\Controller;
|
||||||
|
|
||||||
use Illuminate\Support\ItemNotFoundException;
|
|
||||||
use Krzysiej\RyobiCrawler\Models\Product;
|
use Krzysiej\RyobiCrawler\Models\Product;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
@@ -21,15 +20,32 @@ final class ProductController extends BaseController
|
|||||||
public function __invoke(int $productId): Response
|
public function __invoke(int $productId): Response
|
||||||
{
|
{
|
||||||
$product = Product::with([
|
$product = Product::with([
|
||||||
'price' => fn($query) => $query->orderBy('created_at', 'desc')
|
'price' => fn($query) => $query->orderBy('created_at', 'desc'),
|
||||||
|
'stock' => fn($query) => $query->orderBy('created_at', 'desc'),
|
||||||
])->find($productId);
|
])->find($productId);
|
||||||
|
if (null === $product) {
|
||||||
if(null === $product) {
|
|
||||||
throw $this->createNotFoundException('Product not found');
|
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')->implode(',');
|
return $this->render('product.html.twig', [
|
||||||
$priceDates = $product->price()->pluck('created_at')->map(fn($date) => $date->format('Y-m-d'))->implode("','");
|
'product' => $product,
|
||||||
return $this->render('product.html.twig', ['product' => $product, 'price_list' => $priceList, 'price_dates' => $priceDates]);
|
'price_list' => $this->prepareChartData($priceDates, $priceList),
|
||||||
|
'stock_list' => $this->prepareChartData($stockDates, $stockList),
|
||||||
|
'price_dates' => implode("','", $priceDates),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function prepareChartData($set1, $set2): string
|
||||||
|
{
|
||||||
|
$data = [];
|
||||||
|
foreach ($set1 as $key => $value) {
|
||||||
|
$data[] = ['x' => $value, 'y' => $set2[$key]];
|
||||||
|
}
|
||||||
|
$stringData = json_encode($data);
|
||||||
|
return str_replace(['"x"', '"y"'], ['x', 'y'], $stringData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,11 @@ final class PromosController extends BaseController
|
|||||||
#[Route('/promos', name: 'app_promos')]
|
#[Route('/promos', name: 'app_promos')]
|
||||||
public function __invoke(): Response
|
public function __invoke(): Response
|
||||||
{
|
{
|
||||||
$products = Product::whereHas('currentPrice', fn(Builder $query) => $query->whereColumn('price', '<', 'productStandardPrice'))->with(['currentPrice'])->get();
|
$products = Product::whereHas('currentPrice', fn(Builder $query) => $query->whereColumn('price', '<', 'productStandardPrice'))
|
||||||
|
->orderByDesc('starred')
|
||||||
|
->orderByDesc('created_by')
|
||||||
|
->with(['currentPrice'])
|
||||||
|
->get();
|
||||||
return $this->render('productList.html.twig', ['products' => $products]);
|
return $this->render('productList.html.twig', ['products' => $products]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ final class SearchController extends BaseController
|
|||||||
public function __invoke(Request $request): Response
|
public function __invoke(Request $request): Response
|
||||||
{
|
{
|
||||||
$search = $request->query->get('search');
|
$search = $request->query->get('search');
|
||||||
//dd();
|
|
||||||
$products = Product::with('price')
|
$products = Product::with('price')
|
||||||
->orWhere([['name', 'like', "%$search%"]])
|
->orWhere([['name', 'like', "%$search%"]])
|
||||||
->orWhere([['subTitle', 'like', "%$search%"]])->get();
|
->orWhere([['subTitle', 'like', "%$search%"]])->get();
|
||||||
|
|||||||
@@ -7,11 +7,12 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||||
|
|
||||||
|
use function Symfony\Component\Clock\now;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property integer $skuID
|
* @property integer $skuID
|
||||||
* @property string $name
|
* @property string $name
|
||||||
* @property integer $availableQuantity
|
* @property integer $availableQuantity
|
||||||
* @property integer $stock
|
|
||||||
* @property string[] $categories
|
* @property string[] $categories
|
||||||
* @property string $image
|
* @property string $image
|
||||||
* @property string $subTitle
|
* @property string $subTitle
|
||||||
@@ -32,7 +33,7 @@ class Product extends Model
|
|||||||
|
|
||||||
public function isStarred(): bool
|
public function isStarred(): bool
|
||||||
{
|
{
|
||||||
return (bool) $this->starred;
|
return (bool)$this->starred;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function currentPrice(): HasOne
|
public function currentPrice(): HasOne
|
||||||
@@ -45,6 +46,13 @@ class Product extends Model
|
|||||||
return $this->hasMany(Stock::class);
|
return $this->hasMany(Stock::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function currentStock(): HasOne
|
||||||
|
{
|
||||||
|
return $this->stock()->one()->ofMany()->withDefault(function (Stock $stock) {
|
||||||
|
$stock->stock = 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public function toggleStarred(): self
|
public function toggleStarred(): self
|
||||||
{
|
{
|
||||||
$this->starred = !$this->starred;
|
$this->starred = !$this->starred;
|
||||||
@@ -59,4 +67,13 @@ class Product extends Model
|
|||||||
set: fn(array $value) => json_encode($value),
|
set: fn(array $value) => json_encode($value),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isDiscontinued(): bool
|
||||||
|
{
|
||||||
|
return $this->updated_at->format('Y-m-d') < now()->format('Y-m-d');
|
||||||
|
}
|
||||||
|
public function isNew(): bool
|
||||||
|
{
|
||||||
|
return $this->created_at->format('Y-m-d') > now()->modify('-30 days')->format('Y-m-d');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
53
src/Twig/AppExtension.php
Normal file
53
src/Twig/AppExtension.php
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Krzysiej\RyobiCrawler\Twig;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
use Krzysiej\RyobiCrawler\Models\Price;
|
||||||
|
use Krzysiej\RyobiCrawler\Models\Product;
|
||||||
|
use Krzysiej\RyobiCrawler\Models\Stock;
|
||||||
|
use Twig\Extension\AbstractExtension;
|
||||||
|
use Twig\TwigFilter;
|
||||||
|
use Twig\TwigFunction;
|
||||||
|
|
||||||
|
use function Symfony\Component\Clock\now;
|
||||||
|
|
||||||
|
class AppExtension extends AbstractExtension
|
||||||
|
{
|
||||||
|
public function getFunctions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
new TwigFunction('promosCount', [$this, 'promosCount']),
|
||||||
|
new TwigFunction('newCount', [$this, 'newCount']),
|
||||||
|
new TwigFunction('discontinuedCount', [$this, 'discontinuedCount']),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilters(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
new TwigFilter('findByCreatedAtDate', [$this, 'findByCreatedAtDate']),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function promosCount(): int
|
||||||
|
{
|
||||||
|
return Product::whereHas('currentPrice', fn(Builder $query) => $query->whereColumn('price', '<', 'productStandardPrice'))->with(['currentPrice'])->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function newCount(): int
|
||||||
|
{
|
||||||
|
return Product::where('created_at', '>', now()->modify('-30 days')->format('Y-m-d'))->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function discontinuedCount(): int
|
||||||
|
{
|
||||||
|
return Product::where('updated_at', '<', now()->format('Y-m-d'))->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findByCreatedAtDate(Collection $items, string $date): Stock|Price|null
|
||||||
|
{
|
||||||
|
return $items->first(fn($item) => str_starts_with($item->created_at, $date));
|
||||||
|
}
|
||||||
|
}
|
||||||
6
templates/css/bootstrap.min.css
vendored
Normal file
6
templates/css/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
4
templates/js/script.js
Normal file
4
templates/js/script.js
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
(function() {
|
||||||
|
const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]')
|
||||||
|
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl))
|
||||||
|
})();
|
||||||
@@ -1,74 +1,89 @@
|
|||||||
{% extends "template.html.twig" %}
|
{% extends "template.html.twig" %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
<div class="table-responsive">
|
||||||
<table class='table table-hover'>
|
<table class='table table-hover'>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="align-middle font-weight-bold h3"><a class="text-warning text-decoration-none"
|
<td class="align-middle font-weight-bold h3"><a class="text-warning text-decoration-none"
|
||||||
href="{{ path('app_star', {'productId': product.id}) }}">{% if product.starred %}★{% else %} ☆ {% endif %}</a></td>
|
href="{{ path('app_star', {'productId': product.id}) }}">{% if product.starred %}★{% else %} ☆ {% endif %}</a></td>
|
||||||
<td><img src='{{ product.image }}&width=150' class='border rounded p-1' alt='{{ product.name }}'/></td>
|
<td><img src='{{ product.image }}&width=150' class='border rounded p-1' alt='{{ product.name }}'/></td>
|
||||||
<td><a href='{{ path('app_home') }}/product/{{ product.id }}' class="text-decoration-none">{{ product.name }}</a></td>
|
|
||||||
<td>{{ product.subTitle }}</td>
|
|
||||||
<td>
|
<td>
|
||||||
<ul class='nav'>
|
<a href='{{ path('app_product', {'productId': product.id}) }}' class="text-decoration-none">{{ product.name }}</a>
|
||||||
|
<span class="badge text-bg-light">{{ product.subTitle }}</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<nav aria-label="breadcrumb" style="--bs-breadcrumb-divider: '>';">
|
||||||
|
<ol class="breadcrumb">
|
||||||
{% for category in product.categories %}
|
{% for category in product.categories %}
|
||||||
<li class="nav-item"><a class="nav-link" href="{{ path('app_category', {'category': category}) }}"> {{ category }} </a></li>
|
<li class="breadcrumb-item" aria-current="page"><a class="breadcrumb-item text-decoration-none"
|
||||||
|
href="{{ path('app_category', {'category': category}) }}">{{ category }}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ol>
|
||||||
|
</nav>
|
||||||
</td>
|
</td>
|
||||||
<td><a href='https://pl.ryobitools.eu/{{ product.url }}'>link</a></td>
|
<td><a href='https://pl.ryobitools.eu/{{ product.url }}'>link</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="4">
|
<td colspan="5">
|
||||||
<div style="width: 800px;">
|
<div style="width: 800px;">
|
||||||
<canvas id="price"></canvas>
|
<canvas id="price"></canvas>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="4">
|
<td colspan="5">
|
||||||
<table class='table table-hover table-sm mb-0'>
|
<table class='table table-hover table-sm mb-0'>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>price</th>
|
<th>price</th>
|
||||||
<th>lowest product price in 30 days</th>
|
<th>lowest product price in 30 days</th>
|
||||||
<th colspan='2'>standard price</th>
|
<th colspan='2'>standard price</th>
|
||||||
|
<th>Stock</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
{% for price in product.price %}
|
{% for price in product.price %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ price.price }}</td>
|
<td>{{ price.price | format_currency('PLN', {}, 'pl') }}</td>
|
||||||
<td>{{ price.lowestProductPrice30Days }}</td>
|
<td>{{ price.lowestProductPrice30Days | format_currency('PLN', {}, 'pl') }}</td>
|
||||||
<td>{{ price.productStandardPrice }}</td>
|
<td>{{ price.productStandardPrice | format_currency('PLN', {}, 'pl') }}</td>
|
||||||
<td>{{ price.created_at }}</td>
|
<td>{{ price.created_at }}</td>
|
||||||
|
<td>{{ (product.stock | findByCreatedAtDate(price.created_at | slice(0,10))).stock ?? '' }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const ctx = document.getElementById('price');
|
const ctx = document.getElementById('price').getContext('2d');
|
||||||
|
|
||||||
new Chart(ctx, {
|
new Chart(ctx, {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
data: {
|
data: {
|
||||||
labels: ['{{ price_dates|raw }}'],
|
labels: ['{{ price_dates|raw }}'],
|
||||||
datasets: [{
|
datasets: [
|
||||||
|
{
|
||||||
label: 'Price (PLN)',
|
label: 'Price (PLN)',
|
||||||
data: [{{ price_list }}],
|
data: {{ price_list|raw }},
|
||||||
|
yAxisID: 'yPrice',
|
||||||
|
tension: 0.1,
|
||||||
borderWidth: 1
|
borderWidth: 1
|
||||||
}]
|
},
|
||||||
|
{
|
||||||
|
label: 'Stock (units)',
|
||||||
|
data: {{ stock_list|raw }},
|
||||||
|
yAxisID: 'yStock',
|
||||||
|
tension: 0.1,
|
||||||
|
borderWidth: 1
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
|
responsive: true,
|
||||||
animation: false,
|
animation: false,
|
||||||
plugins: {
|
|
||||||
title: {
|
|
||||||
display: true,
|
|
||||||
text: 'Price in time'
|
|
||||||
},
|
|
||||||
},
|
|
||||||
scales: {
|
scales: {
|
||||||
x: {
|
x: {
|
||||||
title: {
|
title: {
|
||||||
@@ -76,13 +91,40 @@
|
|||||||
text: 'Date'
|
text: 'Date'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
y: {
|
yPrice: {
|
||||||
|
type: 'linear',
|
||||||
|
position: 'left',
|
||||||
beginAtZero: true,
|
beginAtZero: true,
|
||||||
title: {
|
title: {
|
||||||
display: true,
|
display: true,
|
||||||
text: 'Price'
|
text: 'Price (PLN)'
|
||||||
|
},
|
||||||
|
grid: {
|
||||||
|
drawOnChartArea: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
yStock: {
|
||||||
|
type: 'linear',
|
||||||
|
position: 'right',
|
||||||
|
beginAtZero: true,
|
||||||
|
title: {
|
||||||
|
display: true,
|
||||||
|
text: 'Stock (units)'
|
||||||
|
},
|
||||||
|
grid: {
|
||||||
|
drawOnChartArea: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
plugins: {
|
||||||
|
legend: {
|
||||||
|
display: true,
|
||||||
|
position: 'top'
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
display: true,
|
||||||
|
text: 'Price and Stock in time'
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,35 +1,61 @@
|
|||||||
{% extends "template.html.twig" %}
|
{% extends "template.html.twig" %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
<div class="table-responsive">
|
||||||
|
{{ app.request.get('order') }}
|
||||||
<table class='table table-hover'>
|
<table class='table table-hover'>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th>Name</th>
|
<th><a href="{{ path( app.request.get('_route') , {'order': app.request.get('order') is same as('-name')?'name':'-name'|default('-name')}) }}">Name</a></th>
|
||||||
<th class="d-none d-md-table-cell">Code</th>
|
|
||||||
<th>Categories</th>
|
<th>Categories</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th>Price</th>
|
<th><a href="{{ path( app.request.get('_route') , {'order': app.request.get('order') is same as('-price')?'price':'-price'|default('-price')}) }}">Price</a></th>
|
||||||
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
{% for product in products %}
|
{% for product in products %}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="align-middle font-weight-bold h3"><a class="text-warning text-decoration-none" href="{{ path('app_star', {'productId': product.id}) }}">{% if product.starred == true %}★{% else %} ☆ {% endif %}</a></td>
|
<td class="align-middle font-weight-bold h3"><a class="text-warning text-decoration-none"
|
||||||
<td class="align-middle" style="width: 120px;"><img src='{{ product.image }}&width=70' class='border rounded p-1' alt='{{ product.name }}'/></td>
|
href="{{ path('app_star', {'productId': product.id}) }}">{% if product.starred == true %}★{% else %} ☆ {% endif %}</a></td>
|
||||||
<td class="align-middle"><a href='{{ path('app_product', {'productId': product.id}) }}' class="text-decoration-none">{{ product.name }}</a></td>
|
<td class="align-middle" style="width: 120px;"><img src='{{ product.image }}&width=70' class='img-thumbnail' alt='{{ product.name }}'/></td>
|
||||||
<td class="align-middle d-none d-md-table-cell">{{ product.subTitle }}</td>
|
|
||||||
<td class="align-middle">
|
<td class="align-middle">
|
||||||
<ul class='nav'>
|
<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>
|
||||||
|
{% 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>
|
||||||
|
{% endif %}
|
||||||
|
{% if product.isNew() %}
|
||||||
|
<span class="badge text-bg-success">is new</span>
|
||||||
|
{% endif %}
|
||||||
|
<span class="badge text-bg-light">{{ product.subTitle }}</span>
|
||||||
|
</td>
|
||||||
|
<td class="align-middle">
|
||||||
|
<nav aria-label="breadcrumb" style="--bs-breadcrumb-divider: '>';" >
|
||||||
|
<ol class="breadcrumb">
|
||||||
{% for category in product.categories %}
|
{% for category in product.categories %}
|
||||||
<li class="nav-item"><a class="nav-link" href="{{ path('app_category', {'category': category}) }}"> {{ category }} </a></li>
|
<li class="breadcrumb-item" aria-current="page"><a class="breadcrumb-item text-decoration-none" href="{{ path('app_category', {'category': category}) }}">{{ category }}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ol>
|
||||||
|
</nav>
|
||||||
</td>
|
</td>
|
||||||
<td class="align-middle"><a href='https://pl.ryobitools.eu/{{ product.url }}'>link</a></td>
|
<td class="align-middle"><a href='https://pl.ryobitools.eu/{{ product.url }}'>link</a></td>
|
||||||
<td class="align-middle">{{ product.price.last.price }}</td>
|
<td class="align-middle">{{ product.price.last.price | format_currency('PLN', {}, 'pl') }}</td>
|
||||||
<td class="align-middle">{% if product.price.last.price != product.price.last.productStandardPrice %}<span class="text-decoration-line-through text-warning">{{ product.price.last.productStandardPrice }}</span> <span class="text-success">{{ ((1 - product.price.last.price / product.price.last.productStandardPrice)*100)|number_format(0) }}%</span>{% else %}{% endif %}</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>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -5,8 +5,8 @@
|
|||||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
<title>Ryobi crawler</title>
|
<title>Ryobi crawler</title>
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
|
<link href="/templates/css/bootstrap.min.css" rel="stylesheet" />
|
||||||
crossorigin="anonymous"/>
|
<script src="/templates/js/script.js" defer></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav class="navbar navbar-expand-lg sticky-top bg-body-tertiary border-bottom border-secondary border-1">
|
<nav class="navbar navbar-expand-lg sticky-top bg-body-tertiary border-bottom border-secondary border-1">
|
||||||
@@ -19,12 +19,20 @@
|
|||||||
<div class="collapse navbar-collapse" id="navbarNav">
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link active" aria-current="page" href="{{ path('app_promos') }}">Promos</a>
|
<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_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>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link {% if app.request.pathinfo == path('app_discontinued') %}active shadow-sm bg-body rounded{% endif %}" aria-current="page" href="{{ path('app_discontinued') }}">Discontinued <span class="badge text-bg-secondary">{{ discontinuedCount() }}</span></a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<form class="d-flex col-lg-6 col-sm-8" role="search" action="{{ path('app_search') }}">
|
|
||||||
<input class="form-control me-2" type="search" name="search" placeholder="Search term eg. 36v or RCS18X" value="{{ search|default('') }}" aria-label="Search">
|
<form class="form-floating d-flex col-lg-6 col-sm-8" role="search" action="{{ path('app_search') }}">
|
||||||
|
<input class="form-control me-2 form-control-sm" type="search" id="floatingInputValue" name="search" placeholder="Search term eg. 36v or RCS18X" value="{{ search|default('') }}">
|
||||||
<button class="btn btn-outline-success" type="submit">Search</button>
|
<button class="btn btn-outline-success" type="submit">Search</button>
|
||||||
|
<label for="floatingInputValue">Search term eg. 36v or RCS18X</label>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user