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

PICARD-969: Queue search dialog xmlws to run first #620

Conversation

Sophist-UK
Copy link
Contributor

If you are loading a lot of albums and have a long queue of releases being looked up, then the xmlws request for Search for similar albums... is queued behind them.

This commit runs these request as priority=True important=True which means that they will run as the very next xmlws.

https://tickets.metabrainz.org/browse/PICARD-969

If you are loading a lot of albums and have a long queue of releases
being looked up, then the xmlws request for Search for similar albums...
is queued behind them.

This commit runs these request as priority=True important=True which
means that they will run as the very next xmlws.
@Sophist-UK
Copy link
Contributor Author

Away for 2 weeks with email and web but no dev environment - other's can address review comments etc. or they can wait until I am back.

cacheloadcontrol=cacheloadcontrol, refresh=refresh)

def find_releases(self, handler,
xml=True, priority=False, important=False, mblogin=False,
Copy link
Member

Choose a reason for hiding this comment

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

The repitition of keyword arguments in the new code looks unnecessary, why not just pass **kwargs through?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the search terms are also kwargs so this distinguishes between keywords which are Picard internal and those that are part of the search term.

@mineo I still believe that this helps readers distinguish between Picard internal kwargs and search kwargs, but I am not wedded to this.

Now back in the UK and if you still want this simplified after reading my justification, let me know and I will make the changes at some point next week.

Copy link
Member

Choose a reason for hiding this comment

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

Please do, thank you.

@Sophist-UK
Copy link
Contributor Author

Because the search terms are also kwargs so this distinguishes between keywords which are Picard internal and those that are part of the search term.

But not wedded to this. If we still want it changed then it will have to wait for 3-4 weeks until I am back in the uk. Or someone else can change it for me.

@Sophist-UK
Copy link
Contributor Author

Ok - ready for re-review.

Copy link
Member

@mineo mineo left a comment

Choose a reason for hiding this comment

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

This seems to break the "Search for similar tracks" action:

Traceback (most recent call last):
  File "./picard/ui/mainwindow.py", line 819, in show_more_tracks
    dialog.load_similar_tracks(obj)
  File "./picard/ui/searchdialog.py", line 377, in load_similar_tracks
    **query)
  File "./picard/webservice.py", line 497, in find_tracks
    return self._find('recording', handler, kwargs)
  File "./picard/webservice.py", line 477, in _find
    value = escape_lucene_query(value).strip().lower()
  File "./picard/webservice.py", line 66, in escape_lucene_query
    return re.sub(r'([+\-&|!(){}\[\]\^"~*?:\\/])', r'\\\1', text)
  File "/usr/lib/python2.7/re.py", line 155, in sub
    return _compile(pattern, flags).sub(repl, string, count)
TypeError: expected string or buffer

@@ -453,7 +453,9 @@ def lookup_discid(self, discid, handler, priority=True, important=True, refresh=
return self._get_by_id('discid', discid, handler, inc, queryargs={"cdstubs": "no"},
priority=priority, important=important, refresh=refresh)

def _find(self, entitytype, handler, kwargs):
def _find(self, entitytype, handler, kwargs,
Copy link
Member

Choose a reason for hiding this comment

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

You could move the arguments that are only passed to self.get to kwargs here as well. Also, are there plugins that make use of this function? AFAICT all users set priority and important to True, so the defaults should reflect that.

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 suspect that the issue causing the error may be that sometimes we have **kwargs and sometimes we have only kwargs. though I will have to test this.

I am not quite sure what you mean by (but I expect I will work it out when I come to look at the code):

You could move the arguments that are only passed to self.get to kwargs here as well. Also, are there plugins that make use of this function?

I think your point about defaults is well made - I will make this change as soon as I get time to test it.

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 hope I have addressed all review comments - please let me know if I have missed any.

@Sophist-UK
Copy link
Contributor Author

Ok - I think this is ready to merge now. Apologies for poor quality last time.

@Sophist-UK
Copy link
Contributor Author

Travis failure is because Error: Failed to download resource "qt" not because of any coding issue as far as I can tell.


def _browse(self, entitytype, handler, kwargs, inc=[], priority=False, important=False):
def _browse(self, entitytype, handler, inc=[],
xml=True, priority=False, important=False, mblogin=False,
Copy link
Member

Choose a reason for hiding this comment

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

One more thing: why is _browse now neither important nor has it priority? It's used for the other versions context menu item, which seems to be of similar importance as the search for similar tracks...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mineo Thanks for the PR to the branch fr this in my repo. I will look at it more carefully as soon as I have time.

As for this comment - I agree and will change this at the same time as I review your PR.

@Sophist-UK
Copy link
Contributor Author

@mineo please re-review so that this can be merged for 1.4.1

@mineo
Copy link
Member

mineo commented Apr 4, 2017

@Sophist-UK Just in case you're wondering what the status of this is: it looks good now and I'm ok with merging it, but I won't do it right now because using any of the internal search functions of picard immediately crashes it :( (reported as PICARD-1051).

@Sophist-UK
Copy link
Contributor Author

It missed 1.4.1 so there is no rush.

@mineo mineo merged commit c4a6618 into metabrainz:master Apr 4, 2017
mineo added a commit that referenced this pull request Apr 4, 2017
…g-xmlws-to-run-first

PICARD-969: Queue search dialog xmlws to run first
@Sophist-UK
Copy link
Contributor Author

Don't forget to cherry-pick this to 1.4.x.

samj1912 added a commit that referenced this pull request May 7, 2017
Backport of #620 to 1.4.x
Author - Sophist-UK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants