Skip to content

Commit

Permalink
Merge pull request #1138 from acelaya-forks/feature/fix-import-with-n…
Browse files Browse the repository at this point in the history
…o-visits

Feature/fix import with no visits
  • Loading branch information
acelaya authored Aug 2, 2021
2 parents 51c7d0e + e4d4686 commit 32fda23
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org).

## [2.7.3] - 2021-08-02
### Added
* *Nothing*

### Changed
* *Nothing*

### Deprecated
* *Nothing*

### Removed
* *Nothing*

### Fixed
* [#1135](https://github.com/shlinkio/shlink/issues/1135) Fixed error when importing short URLs with no visits from another Shlink instance.
* [#1136](https://github.com/shlinkio/shlink/issues/1136) Fixed error when fetching tag/short-url/orphan visits for a page lower than 1.


## [2.7.2] - 2021-07-30
### Added
* *Nothing*
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"shlinkio/shlink-common": "^3.7",
"shlinkio/shlink-config": "^1.0",
"shlinkio/shlink-event-dispatcher": "^2.1",
"shlinkio/shlink-importer": "^2.3",
"shlinkio/shlink-importer": "^2.3.1",
"shlinkio/shlink-installer": "^6.0",
"shlinkio/shlink-ip-geolocation": "^2.0",
"symfony/console": "^5.1",
Expand Down
2 changes: 1 addition & 1 deletion module/Core/src/Model/ShortUrlsParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ final class ShortUrlsParams
public const DEFAULT_ITEMS_PER_PAGE = 10;

private int $page;
private ?int $itemsPerPage = null;
private ?string $searchTerm;
private array $tags;
private ShortUrlsOrdering $orderBy;
private ?DateRange $dateRange;
private ?int $itemsPerPage = null;

private function __construct()
{
Expand Down
9 changes: 7 additions & 2 deletions module/Core/src/Model/VisitsParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@ public function __construct(
bool $excludeBots = false
) {
$this->dateRange = $dateRange ?? new DateRange();
$this->page = $page;
$this->page = $this->determinePage($page);
$this->itemsPerPage = $this->determineItemsPerPage($itemsPerPage);
$this->excludeBots = $excludeBots;
}

private function determinePage(int $page): int
{
return $page > 0 ? $page : self::FIRST_PAGE;
}

private function determineItemsPerPage(?int $itemsPerPage): int
{
if ($itemsPerPage !== null && $itemsPerPage < 0) {
Expand All @@ -43,7 +48,7 @@ public static function fromRawData(array $query): self
{
return new self(
parseDateRangeFromQuery($query, 'startDate', 'endDate'),
(int) ($query['page'] ?? 1),
(int) ($query['page'] ?? self::FIRST_PAGE),
isset($query['itemsPerPage']) ? (int) $query['itemsPerPage'] : null,
isset($query['excludeBots']),
);
Expand Down

0 comments on commit 32fda23

Please sign in to comment.