Skip to content

Commit

Permalink
Merge pull request #503 from devgeniem/TMS-1013-fix
Browse files Browse the repository at this point in the history
TMS-1013: Skip dynamic events in recurring event checking
  • Loading branch information
eebbi authored Apr 17, 2024
2 parents c5901a5 + 2e89bfc commit 6d7016f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [1.54.9] - 2024-04-18

- TMS-1031: Fix event-component recurring manual-event dates
- TMS-1013: Skip dynamic events in recurring event checking

## [1.54.8] - 2024-04-17

Expand Down
18 changes: 18 additions & 0 deletions lib/Eventz.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public static function normalize_event( $event ) : array {
'links' => $event->links,
'image' => $image ?? null,
'url' => static::get_event_url( $event->_id ),
'is_dynamic' => static::get_dynamic_event( $event->_id ),
];
}

Expand Down Expand Up @@ -518,6 +519,23 @@ public static function get_event_url( string $event_id ) : string {
return '#';
}

/**
* Get dynamic events
*
* @param string $event_id Event's API ID.
*
* @return string
*/
public static function get_dynamic_event( string $event_id ) : string {
$dynamic_events = DynamicEvent::get_link_list();

if ( isset( $dynamic_events[ $event_id ] ) ) {
return true;
}

return false;
}

/**
* Get event date
*
Expand Down
6 changes: 6 additions & 0 deletions lib/Formatters/EventzFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ public static function create_recurring_events( $events, $query_params ) {
foreach ( $events['events'] as $event ) {
$recurring_event_dates = [];

// Show event normally if it's a dynamic event
if ( $event['is_dynamic'] === '1' ) {
$recurring_events[] = $event;
continue;
}

// Chek if event has dates or entries
if ( isset( $event['dates'] ) && count( $event['dates'] ) >= 1 ) {
$recurring_event_dates = $event['dates'];
Expand Down

0 comments on commit 6d7016f

Please sign in to comment.