Skip to content
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

Recurring event: end of #600

Closed
wants to merge 4 commits into from
Closed

Conversation

spitfire305
Copy link
Collaborator

No description provided.

Copy link
Member

@ilestis ilestis left a comment

Choose a reason for hiding this comment

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

Small tweaks to improve performance and code readability.

app/Http/Requests/AddCalendarEvent.php Outdated Show resolved Hide resolved
app/Models/Calendar.php Outdated Show resolved Hide resolved
app/Renderers/CalendarRenderer.php Outdated Show resolved Hide resolved
app/Renderers/CalendarRenderer.php Show resolved Hide resolved
app/Renderers/CalendarRenderer.php Outdated Show resolved Hide resolved
@ilestis
Copy link
Member

ilestis commented Feb 14, 2023

Doesn't seem to work on the yearly view. I have an event set to end in May 2023. On the yearly calendar, it's still showing in december 2023
image
image

On the calendar dashboard, it's not seeing upcoming events happening in a few days
image
image

Copy link
Member

@ilestis ilestis left a comment

Choose a reason for hiding this comment

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

Writing down this review for after the family tree tickets

(!empty($reminder->recurring_until) && empty($reminder->recurring_until_month) && $reminder->recurring_until < $this->currentYear()) ||
(!empty($reminder->recurring_until_month) && empty($reminder->recurring_until_day) && $reminder->recurring_until_month < $this->currentMonth() && $reminder->recurring_until < $this->currentYear()) ||
(!empty($reminder->recurring_until_day) && ($reminder->recurring_until_day < $this->currentDay() && $reminder->recurring_until_month == $this->currentMonth() && $reminder->recurring_until == $this->currentYear() ||
$reminder->recurring_until_month < $this->currentMonth() && $reminder->recurring_until <= $this->currentYear())
Copy link
Member

Choose a reason for hiding this comment

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

Note for later: I'm confused by the logic here, since it's doing the same logic here compared to in the "upcoming" events loop. Shouldn't it do the reverse? And if it's the same, we should remove the copy-pasting and make it a function

// Recurring? We need to switch around the data a bit to figure out the most recent date
if (!empty($this->is_recurring)) {
if ($this->recurringMonthly()) {
//dump('monthly');
$reminderMonth = $month;
Copy link
Member

Choose a reason for hiding this comment

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

Why remove this line? If it's recurring monthly but doesn't have more days, it will be the wrong value, no?

@@ -478,7 +484,9 @@ public function mostRecentOccurrence(int $year, int $month, int $day, array $mon
if ($days > 1 && $this->length > 1) {
$days -= $this->length - 1;
}

if ($overDate) {
$days = -2;
Copy link
Member

Choose a reason for hiding this comment

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

Why are we doing -2 here? It should be detailed in the code what's happening here, and why two.

@@ -576,6 +588,10 @@ public function nextUpcomingOccurrence(int $calendarYear, int $calendarMonth, in
}

$days += ($reminderDay - $day);

if ($overDate) {
Copy link
Member

Choose a reason for hiding this comment

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

Same thing here, why -2 specifically?

//Does the event end this month? if so what day?
//dump($extraDate, $reminder->recurring_until_month);

if (!empty($reminder->recurring_until) && $reminder->recurring_until == $y && !empty($reminder->recurring_until_month) && $reminder->recurring_until_month <= $m) {
Copy link
Member

Choose a reason for hiding this comment

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

Copy-pasted code, should be a single function if

<i class="fa-solid fa-calendar" title="{{ $reminder->readableDate() }}" data-toggle="tooltip" data-placement="bottom"></i>
</div>
{{ link_to($reminder->entity->url(), $reminder->entity->name) }}
@if ($reminder->daysAgo() > -1)
Copy link
Member

Choose a reason for hiding this comment

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

Nested ifs make the code more difficult to read. Instead of

@if ($reminder->daysAgo() <= 0 || !$reminder->entity)
  @continue
@endif

<i class="fa-solid fa-calendar-check" data-toggle="tooltip" title="{{ __('calendars.actions.today') }}"></i>
@else
<i class="fa-solid fa-calendar" title="{{ $reminder->readableDate() }}" data-toggle="tooltip" data-placement="bottom"></i>
@if ($reminder->inDays() > -1)
Copy link
Member

Choose a reason for hiding this comment

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

Same story here, both ifs should be merged into an early continue statement

@ilestis
Copy link
Member

ilestis commented May 24, 2024

Closing this as no one has requested it again

@ilestis ilestis closed this May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants