Browse Source

add-front-to-weather_site

pull/5/head
fedy95 5 years ago
parent
commit
e41c2c0ae1
  1. 7
      docker-compose.yaml
  2. 10
      src/Repository/HistoryRepository.php
  3. 4
      src/Repository/HistoryRepositoryInterface.php
  4. 5
      tests/api/Method/Weather/GetByDateMethodCest.php

7
docker-compose.yaml

@ -1,5 +1,9 @@
version: "3" version: "3"
networks:
gate:
driver: bridge
services: services:
mysql: mysql:
image: mysql:5.7 image: mysql:5.7
@ -44,3 +48,6 @@ services:
- ./devops/docker/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf - ./devops/docker/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf
ports: ports:
- "8$PROJECT_ID:80" - "8$PROJECT_ID:80"
networks:
- default
- gate

10
src/Repository/HistoryRepository.php

@ -16,18 +16,18 @@ class HistoryRepository extends ServiceEntityRepository implements HistoryReposi
parent::__construct($registry, History::class); parent::__construct($registry, History::class);
} }
public function findTempByDateAt(DateTimeInterface $date_at): ?float
public function findTempByDateAt(DateTimeInterface $date_at): array
{ {
$history = $this->findOneBy(['date_at' => $date_at]); $history = $this->findOneBy(['date_at' => $date_at]);
if (null !== $history) { if (null !== $history) {
return $history->getTemp();
return ['temp' => $history->getTemp()];
} }
return null;
return [];
} }
public function findWithLimit(int $limit): ?array
public function findWithLimit(int $limit): array
{ {
$histories = $this->findBy([], ['date_at' => 'DESC'], $limit); $histories = $this->findBy([], ['date_at' => 'DESC'], $limit);
@ -43,6 +43,6 @@ class HistoryRepository extends ServiceEntityRepository implements HistoryReposi
return $result; return $result;
} }
return null;
return [];
} }
} }

4
src/Repository/HistoryRepositoryInterface.php

@ -8,7 +8,7 @@ use DateTimeInterface;
interface HistoryRepositoryInterface interface HistoryRepositoryInterface
{ {
public function findTempByDateAt(DateTimeInterface $date_at): ?float;
public function findTempByDateAt(DateTimeInterface $date_at): array;
public function findWithLimit(int $limit): ?array;
public function findWithLimit(int $limit): array;
} }

5
tests/api/Method/Weather/GetByDateMethodCest.php

@ -43,7 +43,6 @@ class GetByDateMethodCest
'seeResponseMatchesJsonType' => [ 'seeResponseMatchesJsonType' => [
'jsonrpc' => 'string', 'jsonrpc' => 'string',
'id' => 'integer', 'id' => 'integer',
'result' => 'float',
], ],
], ],
[ [
@ -54,12 +53,12 @@ class GetByDateMethodCest
'seeResponseContainsJson' => [ 'seeResponseContainsJson' => [
'jsonrpc' => '2.0', 'jsonrpc' => '2.0',
'id' => 1, 'id' => 1,
'result' => null,
'result' => [],
], ],
'seeResponseMatchesJsonType' => [ 'seeResponseMatchesJsonType' => [
'jsonrpc' => 'string', 'jsonrpc' => 'string',
'id' => 'integer', 'id' => 'integer',
'result' => 'null',
'result' => 'array',
], ],
], ],
[ [