-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert all unrelated commits to this project
- Loading branch information
Showing
142 changed files
with
8,031 additions
and
3,691 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,9 +22,7 @@ APP_SECRET=77edcf2d21c9bb9eb67233d29c618543 | |
|
||
###> doctrine/doctrine-bundle ### | ||
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url | ||
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml | ||
# | ||
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db" | ||
# DATABASE_URL="mysql://db_user:[email protected]:3306/db_name?serverVersion=5.7" | ||
DATABASE_URL=mysql://root:@127.0.0.1:3306/solid?serverVersion=5.7 | ||
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db" | ||
# Configure your db driver and server_version in config/packages/doctrine.yaml | ||
DATABASE_URL=mysql://root:@127.0.0.1:3306/blackfire | ||
###< doctrine/doctrine-bundle ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Hello there! | ||
|
||
The files in this directory cannot be modified directly: we use an internal tool | ||
to manage them. If you find an issue with the code, you can open an issue on the | ||
repository. In fact, that would be awesome :). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
diff --git a/src/Command/UpdateSightingScoresCommand.php b/src/Command/UpdateSightingScoresCommand.php | ||
index 163c167..d279548 100644 | ||
--- a/src/Command/UpdateSightingScoresCommand.php | ||
+++ b/src/Command/UpdateSightingScoresCommand.php | ||
@@ -46,8 +46,8 @@ class UpdateSightingScoresCommand extends Command | ||
|
||
$score = ceil(min($characterCount / 500, 10)); | ||
$sighting->setScore($score); | ||
- $this->entityManager->flush(); | ||
} | ||
+ $this->entityManager->flush(); | ||
$io->progressFinish(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
diff --git a/.blackfire.yaml b/.blackfire.yaml | ||
index 2aeea6b..169cbf4 100644 | ||
--- a/.blackfire.yaml | ||
+++ b/.blackfire.yaml | ||
@@ -15,6 +15,7 @@ scenarios: | | ||
expect status_code() == 200 | ||
expect css("tbody.js-sightings-list tr").count() > 10 | ||
assert metrics.sql.queries.count < 30 | ||
+ assert main.wall_time < 100ms | ||
|
||
click link("Log In") | ||
name "Log in page" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
diff --git a/.blackfire.yaml b/.blackfire.yaml | ||
index 8a2bd73..7f465f2 100644 | ||
--- a/.blackfire.yaml | ||
+++ b/.blackfire.yaml | ||
@@ -3,3 +3,20 @@ | ||
path: "/.*" | ||
assertions: | ||
- "metrics.http.requests.count <= 1" | ||
+ | ||
+scenarios: | | ||
+ #!blackfire-player | ||
+ | ||
+ scenario | ||
+ name "Basic Visit" | ||
+ | ||
+ visit url('/') | ||
+ name "Homepage" | ||
+ expect status_code() == 200 | ||
+ expect css("tbody.js-sightings-list tr").count() > 10 | ||
+ # won't work until we're using Blackfire environment | ||
+ assert metrics.sql.queries.count < 30 | ||
+ | ||
+ click link("Log In") | ||
+ name "Log in page" | ||
+ expect status_code() == 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
diff --git a/.blackfire.yaml b/.blackfire.yaml | ||
index 7f465f2..2aeea6b 100644 | ||
--- a/.blackfire.yaml | ||
+++ b/.blackfire.yaml | ||
@@ -14,7 +14,6 @@ scenarios: | | ||
name "Homepage" | ||
expect status_code() == 200 | ||
expect css("tbody.js-sightings-list tr").count() > 10 | ||
- # won't work until we're using Blackfire environment | ||
assert metrics.sql.queries.count < 30 | ||
|
||
click link("Log In") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
diff --git a/.blackfire.yaml b/.blackfire.yaml | ||
index 169cbf4..be4ff48 100644 | ||
--- a/.blackfire.yaml | ||
+++ b/.blackfire.yaml | ||
@@ -3,6 +3,10 @@ | ||
path: "/.*" | ||
assertions: | ||
- "metrics.http.requests.count <= 1" | ||
+ "Pages are not suddenly *much* slower": | ||
+ path: "/.*" | ||
+ assertions: | ||
+ - "percent(main.wall_time) < 30%" | ||
|
||
scenarios: | | ||
#!blackfire-player |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/.blackfire.yaml b/.blackfire.yaml | ||
index be4ff48..21a6d91 100644 | ||
--- a/.blackfire.yaml | ||
+++ b/.blackfire.yaml | ||
@@ -19,7 +19,7 @@ scenarios: | | ||
expect status_code() == 200 | ||
expect css("tbody.js-sightings-list tr").count() > 10 | ||
assert metrics.sql.queries.count < 30 | ||
- assert main.wall_time < 100ms | ||
+ assert main.wall_time < (100ms * var('speed_coefficient', 1)) | ||
|
||
click link("Log In") | ||
name "Log in page" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
diff --git a/src/Service/CommentHelper.php b/src/Service/CommentHelper.php | ||
index 7a96a4f..f2bff11 100644 | ||
--- a/src/Service/CommentHelper.php | ||
+++ b/src/Service/CommentHelper.php | ||
@@ -3,20 +3,20 @@ | ||
namespace App\Service; | ||
|
||
use App\Entity\User; | ||
+use App\Repository\CommentRepository; | ||
|
||
class CommentHelper | ||
{ | ||
- public function countRecentCommentsForUser(User $user): int | ||
+ private $commentRepository; | ||
+ | ||
+ public function __construct(CommentRepository $commentRepository) | ||
{ | ||
- $comments = $user->getComments(); | ||
- $commentCount = 0; | ||
- $recentDate = new \DateTimeImmutable('-3 months'); | ||
- foreach ($comments as $comment) { | ||
- if ($comment->getCreatedAt() > $recentDate) { | ||
- $commentCount++; | ||
- } | ||
- } | ||
+ $this->commentRepository = $commentRepository; | ||
+ } | ||
|
||
- return $commentCount; | ||
+ public function countRecentCommentsForUser(User $user): int | ||
+ { | ||
+ return $this->commentRepository | ||
+ ->countForUser($user, new \DateTimeImmutable('-3 months')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
diff --git a/src/Twig/AppExtension.php b/src/Twig/AppExtension.php | ||
index 2cd5e63..7be2947 100644 | ||
--- a/src/Twig/AppExtension.php | ||
+++ b/src/Twig/AppExtension.php | ||
@@ -12,6 +12,8 @@ class AppExtension extends AbstractExtension | ||
{ | ||
private $commentHelper; | ||
|
||
+ private $userStatuses = []; | ||
+ | ||
public function __construct(CommentHelper $commentHelper) | ||
{ | ||
$this->commentHelper = $commentHelper; | ||
@@ -25,6 +27,15 @@ class AppExtension extends AbstractExtension | ||
} | ||
|
||
public function getUserActivityText(User $user): string | ||
+ { | ||
+ if (!isset($this->userStatuses[$user->getId()])) { | ||
+ $this->userStatuses[$user->getId()] = $this->calculateUserActivityText($user); | ||
+ } | ||
+ | ||
+ return $this->userStatuses[$user->getId()]; | ||
+ } | ||
+ | ||
+ private function calculateUserActivityText(User $user): string | ||
{ | ||
$commentCount = $this->commentHelper->countRecentCommentsForUser($user); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
diff --git a/src/Twig/AppExtension.php b/src/Twig/AppExtension.php | ||
index 7be2947..4a18185 100644 | ||
--- a/src/Twig/AppExtension.php | ||
+++ b/src/Twig/AppExtension.php | ||
@@ -12,8 +12,6 @@ class AppExtension extends AbstractExtension | ||
{ | ||
private $commentHelper; | ||
|
||
- private $userStatuses = []; | ||
- | ||
public function __construct(CommentHelper $commentHelper) | ||
{ | ||
$this->commentHelper = $commentHelper; | ||
@@ -28,11 +26,7 @@ class AppExtension extends AbstractExtension | ||
|
||
public function getUserActivityText(User $user): string | ||
{ | ||
- if (!isset($this->userStatuses[$user->getId()])) { | ||
- $this->userStatuses[$user->getId()] = $this->calculateUserActivityText($user); | ||
- } | ||
- | ||
- return $this->userStatuses[$user->getId()]; | ||
+ return $this->calculateUserActivityText($user); | ||
} | ||
|
||
private function calculateUserActivityText(User $user): string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/.env b/.env | ||
index 1f68332..ac88cd0 100644 | ||
--- a/.env | ||
+++ b/.env | ||
@@ -14,7 +14,7 @@ | ||
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration | ||
|
||
###> symfony/framework-bundle ### | ||
-APP_ENV=dev | ||
+APP_ENV=prod | ||
APP_SECRET=77edcf2d21c9bb9eb67233d29c618543 | ||
#TRUSTED_PROXIES=127.0.0.1,127.0.0.2 | ||
#TRUSTED_HOSTS='^localhost|example\.com$' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
diff --git a/src/Twig/AppExtension.php b/src/Twig/AppExtension.php | ||
index 4a18185..eb73e33 100644 | ||
--- a/src/Twig/AppExtension.php | ||
+++ b/src/Twig/AppExtension.php | ||
@@ -4,6 +4,8 @@ namespace App\Twig; | ||
|
||
use App\Entity\User; | ||
use App\Service\CommentHelper; | ||
+use Psr\Cache\CacheItemInterface; | ||
+use Symfony\Contracts\Cache\CacheInterface; | ||
use Twig\Extension\AbstractExtension; | ||
use Twig\TwigFilter; | ||
use Twig\TwigFunction; | ||
@@ -11,10 +13,12 @@ use Twig\TwigFunction; | ||
class AppExtension extends AbstractExtension | ||
{ | ||
private $commentHelper; | ||
+ private $cache; | ||
|
||
- public function __construct(CommentHelper $commentHelper) | ||
+ public function __construct(CommentHelper $commentHelper, CacheInterface $cache) | ||
{ | ||
$this->commentHelper = $commentHelper; | ||
+ $this->cache = $cache; | ||
} | ||
|
||
public function getFilters(): array | ||
@@ -26,7 +30,13 @@ class AppExtension extends AbstractExtension | ||
|
||
public function getUserActivityText(User $user): string | ||
{ | ||
- return $this->calculateUserActivityText($user); | ||
+ $key = sprintf('user_activity_text_'.$user->getId()); | ||
+ | ||
+ return $this->cache->get($key, function(CacheItemInterface $item) use ($user) { | ||
+ $item->expiresAfter(3600); | ||
+ | ||
+ return $this->calculateUserActivityText($user); | ||
+ }); | ||
} | ||
|
||
private function calculateUserActivityText(User $user): string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
diff --git a/.blackfire.yaml b/.blackfire.yaml | ||
new file mode 100644 | ||
index 0000000..8a2bd73 | ||
--- /dev/null | ||
+++ b/.blackfire.yaml | ||
@@ -0,0 +1,5 @@ | ||
+"tests": | ||
+ "HTTP Requests should be limited to 1 per page": | ||
+ path: "/.*" | ||
+ assertions: | ||
+ - "metrics.http.requests.count <= 1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/src/Entity/BigFootSighting.php b/src/Entity/BigFootSighting.php | ||
index 1e1f5eb..daf6cbf 100644 | ||
--- a/src/Entity/BigFootSighting.php | ||
+++ b/src/Entity/BigFootSighting.php | ||
@@ -55,7 +55,7 @@ class BigFootSighting | ||
private $createdAt; | ||
|
||
/** | ||
- * @ORM\OneToMany(targetEntity="App\Entity\Comment", mappedBy="bigFootSighting") | ||
+ * @ORM\OneToMany(targetEntity="App\Entity\Comment", mappedBy="bigFootSighting", fetch="EXTRA_LAZY") | ||
* @ORM\OrderBy({"createdAt"="DESC"}) | ||
*/ | ||
private $comments; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/src/Repository/BigFootSightingRepository.php b/src/Repository/BigFootSightingRepository.php | ||
index 7aa4416..d0a075a 100644 | ||
--- a/src/Repository/BigFootSightingRepository.php | ||
+++ b/src/Repository/BigFootSightingRepository.php | ||
@@ -23,8 +23,6 @@ class BigFootSightingRepository extends ServiceEntityRepository | ||
public function findLatestQueryBuilder(int $maxResults): QueryBuilder | ||
{ | ||
return $this->createQueryBuilder('big_foot_sighting') | ||
- ->leftJoin('big_foot_sighting.comments', 'comments') | ||
- ->addSelect('comments') | ||
->setMaxResults($maxResults) | ||
->orderBy('big_foot_sighting.createdAt', 'DESC'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/src/Repository/BigFootSightingRepository.php b/src/Repository/BigFootSightingRepository.php | ||
index d0a075a..7aa4416 100644 | ||
--- a/src/Repository/BigFootSightingRepository.php | ||
+++ b/src/Repository/BigFootSightingRepository.php | ||
@@ -23,6 +23,8 @@ class BigFootSightingRepository extends ServiceEntityRepository | ||
public function findLatestQueryBuilder(int $maxResults): QueryBuilder | ||
{ | ||
return $this->createQueryBuilder('big_foot_sighting') | ||
+ ->leftJoin('big_foot_sighting.comments', 'comments') | ||
+ ->addSelect('comments') | ||
->setMaxResults($maxResults) | ||
->orderBy('big_foot_sighting.createdAt', 'DESC'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
diff --git a/scenario.bkf b/scenario.bkf | ||
index d2a095c..68a9636 100644 | ||
--- a/scenario.bkf | ||
+++ b/scenario.bkf | ||
@@ -8,6 +8,9 @@ scenario | ||
|
||
visit url("/") | ||
name "Homepage" | ||
+ expect status_code() == 200 | ||
|
||
click link("Log In") | ||
name "Login page" | ||
+ expect status_code() == 200 | ||
+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
diff --git a/scenario.bkf b/scenario.bkf | ||
index feca60f..d2a095c 100644 | ||
--- a/scenario.bkf | ||
+++ b/scenario.bkf | ||
@@ -2,3 +2,12 @@ name "Various scenarios for the site" | ||
|
||
# override with --endpoint option | ||
endpoint "https://localhost:8000" | ||
+ | ||
+scenario | ||
+ name "Basic Visit" | ||
+ | ||
+ visit url("/") | ||
+ name "Homepage" | ||
+ | ||
+ click link("Log In") | ||
+ name "Login page" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
diff --git a/scenario.bkf b/scenario.bkf | ||
index 68a9636..5eb1447 100644 | ||
--- a/scenario.bkf | ||
+++ b/scenario.bkf | ||
@@ -9,6 +9,7 @@ scenario | ||
visit url("/") | ||
name "Homepage" | ||
expect status_code() == 200 | ||
+ expect css("tbody.js-sightings-list tr").count() > 500 | ||
|
||
click link("Log In") | ||
name "Login page" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
diff --git a/scenario.bkf b/scenario.bkf | ||
new file mode 100644 | ||
index 0000000..feca60f | ||
--- /dev/null | ||
+++ b/scenario.bkf | ||
@@ -0,0 +1,4 @@ | ||
+name "Various scenarios for the site" | ||
+ | ||
+# override with --endpoint option | ||
+endpoint "https://localhost:8000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/scenario.bkf b/scenario.bkf | ||
index 92be148..8a58fb0 100644 | ||
--- a/scenario.bkf | ||
+++ b/scenario.bkf | ||
@@ -10,6 +10,8 @@ scenario | ||
name "Homepage" | ||
expect status_code() == 200 | ||
expect css("tbody.js-sightings-list tr").count() > 10 | ||
+ # won't work until we're using Blackfire environment | ||
+ assert metrics.sql.queries.count < 30 | ||
|
||
click link("Log In") | ||
name "Login page" |
Oops, something went wrong.