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

Creating a legacy Redia RSS feed for events. DDFHER-60 #1584

Merged
merged 5 commits into from
Oct 8, 2024

Conversation

rasben
Copy link
Contributor

@rasben rasben commented Sep 18, 2024

This feed is needed for some legacy apps to continue working. It will not be updated in the future - rather, this is a 1-1 recreation of the old feed.

As I've made a custom redia legacy module, i've also moved the legacy opening hours REST api into this module.

Link to issue

https://reload.atlassian.net/browse/DDFHER-60

Old feed:

https://www.aakb.dk/ding-redia-rss/event

New feed:

https://varnish.pr-1584.dpl-cms.dplplat01.dpl.reload.dk/ding-redia-rss/event

@github-actions github-actions bot temporarily deployed to pr-1584 September 18, 2024 08:43 Destroyed
@rasben rasben force-pushed the DDFHER-60_redia-events branch from 0b99bf6 to a3ae90e Compare September 18, 2024 08:45
@github-actions github-actions bot temporarily deployed to pr-1584 September 18, 2024 08:45 Destroyed
This feed is needed for some legacy apps to continue working.
It will not be updated in the future - rather, this is a
1-1 recreation of the old feed.

As I've made a custom redia legacy module, i've also moved the
legacy opening hours REST api into this module.
@rasben rasben force-pushed the DDFHER-60_redia-events branch from a3ae90e to 79168fa Compare September 18, 2024 08:51
@github-actions github-actions bot temporarily deployed to pr-1584 September 18, 2024 08:51 Destroyed
Copy link
Contributor

@kasperg kasperg left a comment

Choose a reason for hiding this comment

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

Lots of code, lots of comments here 😅 .

I think it is a good idea to create a separate module for the legacy integrations and as I see it you have managed to recreate the feed 1-1 compared to the original.

There are a couple of places where we disagree on the overall code structure:

  • I would like to see the EventWrapper used more.
  • I would prefer more proper objects and less arrays and strings.

config/sync/core.extension.yml Show resolved Hide resolved
Comment on lines 52 to 55
$response = new Response();
$response->setContent($rss_content);
$response->headers->set('Content-Type', 'application/rss+xml');
return $response;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please update this to return a cacheable response.

I do not know how often the feed is requested but I do not see a reason why we should not be able to cache it in Varnish.

Copy link
Contributor

Choose a reason for hiding this comment

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

As I see it you have changes the implementation to return a cacheable response but please also add some cacheable dependencies to make it behave right 😄

config/sync/image.style.redia_feed_large.yml Show resolved Hide resolved
@kasperg kasperg assigned rasben and unassigned kasperg, xendk and kasperbirch1 Sep 20, 2024
@github-actions github-actions bot temporarily deployed to pr-1584 September 20, 2024 12:35 Destroyed
As per PR change requests, I've switched up the code
to use the existing EventWrapper, using OOP rather than
array loops, and generally making the RSS code more
readable.
@rasben rasben force-pushed the DDFHER-60_redia-events branch from 37d2ad7 to 873aa38 Compare October 1, 2024 09:37
@github-actions github-actions bot temporarily deployed to pr-1584 October 1, 2024 09:38 Destroyed
/**
* Getting the description, from the first available text paragraph.
*/
public function getDescription(): ?string {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've moved this, from EventRestMapper, as now we use it in two places.

@rasben
Copy link
Contributor Author

rasben commented Oct 1, 2024

@kasperg This is ready for you again. All the relevant changes have been added in the latest commit :) ("Refactor...")

@rasben rasben assigned kasperg and unassigned rasben Oct 1, 2024
web/modules/custom/dpl_update/dpl_update.install Outdated Show resolved Hide resolved
$branches = $event->get('branch')->referencedEntities();
$branch = reset($branches);
$event_dates = $event->get('date')->getValue();
$changed_date = DrupalDateTime::createFromFormat('U', strval($event->getChangedTime()));
Copy link
Contributor

Choose a reason for hiding this comment

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

As I see it the code remains. Is that intentional?

/**
* An event object, containing the properties the RSS feed needs.
*/
class RediaEvent extends ControllerBase {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please reconsider if this class and RediaEventMedia needs to extend ControllerBase.

I do not understand why this is necessary. As I see it the class is not a controller and it does not utilize any methods provided by the parent class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They both utilize EntityTypeManager, that comes from that :)

Comment on lines +16 to +18
// We'll disable the documentation rules for the member properties, as
// they are pretty self-explanatory.
// phpcs:disable
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider if is it possible to only disable the related rules for these lines instead of PHPCS entirely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did try, and it just refused to accept it, so this is me going nuclear.

Comment on lines 186 to 187
$current_date = new DrupalDateTime();
$date = $current_date->format('r');
Copy link
Contributor

Choose a reason for hiding this comment

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

Getting the current time is a dependency which should be injected instead of accessed directly.

@github-actions github-actions bot temporarily deployed to pr-1584 October 7, 2024 12:21 Destroyed
@github-actions github-actions bot temporarily deployed to pr-1584 October 7, 2024 15:02 Destroyed
@kasperg kasperg merged commit 6565b36 into develop Oct 8, 2024
19 checks passed
@kasperg kasperg deleted the DDFHER-60_redia-events branch October 8, 2024 15:21
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.

4 participants