-
Notifications
You must be signed in to change notification settings - Fork 87
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
Allow filtering by category #203
Conversation
The 'type' key is probably redundant here, but it's in the default config already. This doesn't display anything in the queue filter GUI. Bug: T72723
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you try if this works? How do you specify categories and where do you store them? I am not sure what these 3 new variables in QueueFilter are good for.
huggle/hugglequeuefilter.cpp
Outdated
@@ -75,6 +75,9 @@ HuggleQueueFilter::HuggleQueueFilter() | |||
this->Users = HuggleQueueFilterMatchIgnore; | |||
this->TalkPage = HuggleQueueFilterMatchExclude; | |||
this->UserSpace = HuggleQueueFilterMatchIgnore; | |||
this->Type = "default"; | |||
this->SourceType = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really know why this compiles, there is probably an operator override, but you shouldn't assign nullptr to an object, this->Type is not a pointer, it's object. There is no need to initialize it, it's done implicitly by constructor of QString
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for other QString
huggle/hugglequeuefilter.hpp
Outdated
@@ -113,6 +119,9 @@ namespace Huggle | |||
HuggleQueueFilterMatch Self; | |||
HuggleQueueFilterMatch UserSpace; | |||
HuggleQueueFilterMatch TalkPage; | |||
QString Type; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is "Type" for? Does it identify a "type" of filter? I see that so far you always use either "default" or "dynamic", if that is the case, why do you need to store this in a string? Wouldn't it be more efficient to use enumeration which is far more memory and CPU efficient?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW what is difference between "default" and "dynamic"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked more into this I don't really understand what is point of all these 3 variables? Filter is only 1 for whole queue, so list of categories you want to exclude, or require should be defined in each filter separately. What are these 3 variables for? And how do you store a list of categories that user wants to filter now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variables are set in the DefaultConfig
We could allow filtering for one of (or all of) a set of categories if you want
huggle/hugglequeuefilter.cpp
Outdated
@@ -157,6 +160,13 @@ bool HuggleQueueFilter::Matches(WikiEdit *edit) | |||
if (this->Self == HuggleQueueFilterMatchRequire && edit->User->Username.toLower() == Configuration::HuggleConfiguration->SystemConfig_Username.toLower()) | |||
return false; | |||
} | |||
if (this->Type == "dynamic" && this->SourceType == "category") | |||
{ | |||
if (edit->Status == StatusPostProcessed && !edit->Page->GetCategories().contains(QString("Category:") + this->Source)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work on wikis other than English? I think that mediawiki localizes the page name, so "Category:" would probably be substituted. In that case you can use help of WikiSite object which contains a list of namespaces (NamespaceList), each namespace in huggle contains canonical name which can be retrieved using "GetCanonicalName()"
{ | ||
if (this->qCategories->IsFailed()) | ||
{ | ||
Syslog::HuggleLogs->ErrorLog("Unable to fetch categories for page " + this->Page->PageName + ": " + this->qCategories->GetFailureReason()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This string is error for user, so it probably should be made localizable (just replace it with something like _l("category-fetch-fail", this->Page->PageName, this->qCategories->GetFailureReason()) and add that string to Localization/en.xml)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was just following the existing pattern for other post-process queries
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes they all need to be made translatable, there is a GCI task for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I'll leave this as is and it can be followed up with the GCI task?
I'm still learning C++
Don't hardcode the category namespace name to prepend to the filter source, instead, strip it from the categories of the page.
I have tested this with the default "Candidates for speedy deletion" filter. I created my own in https://en.wikipedia.org/w/index.php?title=User%3AKrenair%2Fhuggle3.css&type=revision&diff=773914330&oldid=773805466 |
OK, But I think of a little different design here, basically right now we can have only 1 filter active in a moment. The way how you implemented this, it's not possible to filter multiple categories in each filter. Imagine someone wanted to create a filter that ignores talk pages, bots and registered users and wants to see only pages in category "United States" which also are not in category "Presidents" and "Politicians". This is not possible with your design. So what I propose (I still don't understand what is meaning of these 3 variables you created, but whatever) - add this filter in same way as tag filter was implemented. Add 2 string lists "IgnoreCats" and "RequireCats" and let user define a list of categories for each (separated either by comma or newline, I don't know what is better). Then the filter would just look if wikiedit has all "RequireCats" and doesn't have any of "IgnoreCats". I hope it's clear what I mean :) |
And in your configuration file huggle3.css it would look like this:
I omitted these 3 variables you added because I just don't understand their purpose. However this is I believe what users on feedback page wanted to have |
Sure, I was just trying to stick to the existing config. I'll change it around to work like that. |
By the way, why does a lot of the default config appear to not be used? |
Because huggle3 is a rewrite of older version of huggle. Some of these were not implemented yet. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, are you going to implement UI as well?
@benapetr: I don't think the GUI commit got merged? |
nevermind, it got merged, had some issues with git. the way github merges commits together is a bit strange |
This doesn't display anything in the queue filter GUI yet. That'll be a future commit.
Bug: T72723