8000 Support for redirects with a condition before date by vaslv · Pull Request #2434 · shlinkio/shlink · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Support for redirects with a condition before date #2434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

vaslv
Copy link
@vaslv vaslv commented May 7, 2025

Added one of the date-based conditions (before-date)

#2431
https://github.com/shlinkio/shlink/discussions/2101#discussioncomment-9108182

@acelaya
Copy link
Member
acelaya commented May 11, 2025

I've checked this in diagonal, but it looks good in general.

I'll approve the CI execution so that you can fix anything that fails, and I'll try to come back to it in a couple weeks and do a proper review.

Copy link
codecov bot commented May 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.82%. Comparing base (27d24a4) to head (9e6b6fb).
Report is 1 commits behind head on develop.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #2434      +/-   ##
=============================================
+ Coverage      93.81%   93.82%   +0.01%     
- Complexity      1707     1713       +6     
=============================================
  Files            277      277              
  Lines           5918     5928      +10     
=============================================
+ Hits            5552     5562      +10     
  Misses           366      366              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vaslv
Copy link
Author
vaslv commented May 12, 2025

If everything is fine and no edits are needed, I’ll create the after-date condition in the same way.

@vaslv
Copy link
Author
vaslv commented May 24, 2025

Hi! Let's continue working? I want to use the feature in production!

@acelaya
Copy link
Member
acelaya commented May 24, 2025

Hi! Let's continue working? I want to use the feature in production!

I think I clearly explained it would take quite some time for me to be able to focus on reviewing this #2431 (comment)

Also, after merging, it will have to wait for the rest of the features in 4.5 to be implemented before releasing it, so don't expect this to be available before the end of the year.

Copy link
Member
@acelaya acelaya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your patience, but I wanted to avoid spreading my attention among multiple topics, as that usually means getting nothing done.

I suggested a small change to type the date as Chronos in RedirectCondition::forBeforeDate(), but other than that, this looks good to me.

You'll need to rebase develop, as there seems to be some conflicts.

Comment on lines +68 to +71
public static function forBeforeDate(string $date): self
{
return new self(RedirectConditionType::BEFORE_DATE, $date);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if this should be typed as Chronos, and do the cast to string here.

Suggested change
public static function forBeforeDate(string $date): self
{
return new self(RedirectConditionType::BEFORE_DATE, $date);
}
public static function forBeforeDate(Chronos $date): self
{
return new self(RedirectConditionType::BEFORE_DATE, $date->toAtomString());
}

That would be more in line with methods like forDevice, where DeviceType is expected, not string, and the casting is done there appropriately, avoiding user errors.

That means the value needs to be converted from the input string to Chronos somewhere, but I think that's fine, as that can be done with normalizeDate

Comment on lines +169 to +170
yield 'date later than current' => [Chronos::now()->addHours(1)->toIso8601String(), true];
yield 'date earlier than current' => [Chronos::now()->subHours(1)->toIso8601String(), false];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per my previous comment, you can probably pass a raw Chronos object here.

Suggested change
7FA5
yield 'date later than current' => [Chronos::now()->addHours(1)->toIso8601String(), true];
yield 'date earlier than current' => [Chronos::now()->subHours(1)->toIso8601String(), false];
yield 'date later than current' => [Chronos::now()->addHours(1), true];
yield 'date earlier than current' => [Chronos::now()->subHours(1), false];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0