Skip to content

Simplify metric explorer getFormat#2189

Open
ryanrath wants to merge 4 commits into
ubccr:mainfrom
ryanrath:simplify_me_formats
Open

Simplify metric explorer getFormat#2189
ryanrath wants to merge 4 commits into
ubccr:mainfrom
ryanrath:simplify_me_formats

Conversation

@ryanrath
Copy link
Copy Markdown
Contributor

Description

Refactored getFormat to the much simpler new function validateFormat and removed getFormat.

Motivation and Context

These changes are to address the points raised in: https://github.com/ubccr/xdmod-xsede/issues/1154

Tests performed

All automated tests.

Checklist:

  • The pull request description is suitable for a Changelog entry
  • The milestone is set correctly on the pull request
  • The appropriate labels have been added to the pull request

@ryanrath ryanrath added this to the 11.5.0 milestone Apr 14, 2026
@ryanrath ryanrath added maintenance / code quality Improvements and code cleanup. Not a new feature or enhancement to existing functionality. autodoc:ignore Auto documentation ignore this PR Category:Infrastructure Internal infrastructure updates/changes labels Apr 14, 2026
@ryanrath ryanrath requested review from aestoltm and connersaeli and removed request for connersaeli April 14, 2026 14:41
@ryanrath ryanrath changed the title Simplify me formats Simplify metric explorer getFormat Apr 14, 2026
Comment on lines +18 to +19
if (isset($request['format'])) {
$requestedFormat = strtolower($request['format']);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is $request[] supposed to be $REQUEST here? I know the symfony code doesn't deal with the super global directly anymore but I think it is supposed to be that here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it is and I'm not sure why it was changed, I'll change it back.

$this->request = array_merge($config, $this->request);
$requestedFormat = 'csv';
if (isset($this->request['format'])) {
$requestedFormat = strtolower($this->request['format']);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is the purpose of the strtolower call here? There is also a strtolower call in the validateFormat function.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just a hold over from the original code, this and the other strtolower will be removed.

Comment thread classes/DataWarehouse/ExportBuilder.php Outdated
* @param array $allowedFormats
* @return string
*/
public static function validateFormat(?string $requestedFormat, string $default = 'jsonstore', array $allowedFormats = []): string
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is requestedFormat allowed to be not set? What circumstances would cause it to be not set and why do we want to support this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I believe it was something I ran into while testing, but honestly it should never be null. I've tested removing the nullable and all tests passed so I'll be removing it

$_REQUEST = array_merge($config, $_REQUEST);
$requestedFormat = null;
if (isset($request['format'])) {
$requestedFormat = strtolower($request['format']);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same question about the strtolower call here: why is it being done when it is also called in the validateFormat function

Comment thread classes/DataWarehouse/ExportBuilder.php Outdated
* @param array $allowedFormats
* @return string
*/
public static function validateFormat(?string $requestedFormat, string $default = 'jsonstore', array $allowedFormats = []): string
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is the design reason for having default values for the $default and the $allowedFormats parameters? Where is this function called when these defaults are used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Really it was just because the "ancestor" function getFormat had a $default and a $formats_subset ( which I renamed to $allowedFormats so that it made more sense. ). It's never called without a $default or a $allowedFormats argument. I'll go ahead and remove those arguments.

@ryanrath
Copy link
Copy Markdown
Contributor Author

@jpwhite4 @aestoltm I've pushed changes based on your review comments, could you take another look when you have a sec.

@ryanrath ryanrath requested review from aestoltm and jpwhite4 April 23, 2026 13:30
@ryanrath ryanrath force-pushed the simplify_me_formats branch from f5d9f46 to 30286ad Compare April 24, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autodoc:ignore Auto documentation ignore this PR Category:Infrastructure Internal infrastructure updates/changes maintenance / code quality Improvements and code cleanup. Not a new feature or enhancement to existing functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants