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

Omit the need to call all modifiers. #11

Merged
merged 2 commits into from Sep 16, 2020
Merged

Omit the need to call all modifiers. #11

merged 2 commits into from Sep 16, 2020

Conversation

uttkarsh-26
Copy link

@uttkarsh-26 uttkarsh-26 commented Sep 14, 2020

https://github.com/openscholar/openscholar/issues/14405

I thought it would be better if we can totally omit the need to call all the modifiers rather them calling them all once and caching (that would still mean that every time cache is invalidated we need to query the DB multiple times), when we know that modifier is to be matched from the uri, why not use the URI to get the modifier and just match that rather than getting all modifiers by querying the DB (as many times as is the vsite count on the install) and then matching them one by one.

This does need some changes in group purl module too for which I am in process of creating patches and also am testing out certain aspects and fixing some notices being thrown. (This did need some thought and trying out multiple things to get everything working as before, but for this PR more or less this should be final code.)

Raising this PR so that this can be reviewed till then and potential side effects can be assessed which can impact currently or in future.
@rbran100 @Bilsi @jashish24

Copy link
Member

@rbran100 rbran100 left a comment

Choose a reason for hiding this comment

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

I agree with the path you are taking, but any caching probably needs to happen in the group_purl code, you might still be able to fit your pattern.


// Eliminate the need to get and iterate through all the modifiers as it is
// a very resource intensive process.
$provider = Provider::load(self::GROUP_PURL_PROVIDER);
Copy link
Member

Choose a reason for hiding this comment

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

We can not just call the GROUP_PURL_PROVIDER as we will soon have multiple providers for domain in addition to path prefix, also purl should not be dependent on group_purl.

$provider_plugin = $this->provider->getProviderPlugin();
}
if ($provider_plugin) {
$modifier = $provider_plugin->getModifierDataByKey($uri);
Copy link
Member

Choose a reason for hiding this comment

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

The uri will not always be the key for all providers/modifiers, the providers will need the entire request to make their determination.

@uttkarsh-26
Copy link
Author

I agree with the path you are taking, but any caching probably needs to happen in the group_purl code, you might still be able to fit your pattern.

I also doubted it that's why thought to get validation on this. anyways will see something else tomorrow in the same direction.

@@ -41,7 +41,7 @@ public function getProviderModifiersByKey(Provider $provider, $key)
{
$modifiers = [];

if (method_exists($provider->getProviderPlugin(), 'getModifierDataByValue')) {
if (method_exists($provider->getProviderPlugin(), 'getModifierDataByKey')) {
Copy link
Author

Choose a reason for hiding this comment

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

still need this I think, because inside the if it calls getModifierDataByKey

@rbran100 rbran100 merged commit cd52d90 into master Sep 16, 2020
@rbran100 rbran100 deleted the Purl-optimization branch September 16, 2020 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants