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

Allow filtering by category #203

Merged
merged 6 commits into from
Apr 7, 2017
Merged

Allow filtering by category #203

merged 6 commits into from
Apr 7, 2017

Conversation

Krenair
Copy link
Contributor

@Krenair Krenair commented Apr 5, 2017

This doesn't display anything in the queue filter GUI yet. That'll be a future commit.

Bug: T72723

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
@benapetr benapetr self-requested a review April 5, 2017 11:40
Copy link
Member

@benapetr benapetr left a 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.

@@ -75,6 +75,9 @@ HuggleQueueFilter::HuggleQueueFilter()
this->Users = HuggleQueueFilterMatchIgnore;
this->TalkPage = HuggleQueueFilterMatchExclude;
this->UserSpace = HuggleQueueFilterMatchIgnore;
this->Type = "default";
this->SourceType = nullptr;
Copy link
Member

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

Copy link
Member

Choose a reason for hiding this comment

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

Same for other QString

@@ -113,6 +119,9 @@ namespace Huggle
HuggleQueueFilterMatch Self;
HuggleQueueFilterMatch UserSpace;
HuggleQueueFilterMatch TalkPage;
QString Type;
Copy link
Member

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?

Copy link
Member

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"?

Copy link
Member

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?

Copy link
Contributor Author

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

@@ -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))
Copy link
Member

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());
Copy link
Member

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)

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 think this was just following the existing pattern for other post-process queries

Copy link
Member

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

Copy link
Contributor Author

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.
@Krenair
Copy link
Contributor Author

Krenair commented Apr 5, 2017

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

@benapetr
Copy link
Member

benapetr commented Apr 6, 2017

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 :)

@benapetr
Copy link
Member

benapetr commented Apr 6, 2017

And in your configuration file huggle3.css it would look like this:

queues:
    User defined queue #9:
        filter-ignored:exclude
        filter-bots:exclude
        filter-assisted:exclude
        filter-ip:ignore
        filter-minor:ignore
        filter-new-pages:ignore
        filter-me:exclude
        filter-users:ignore
        nsfilter-user:ignore
        filter-talk:exclude
        ignored-tags:mobileaedit,asd
        required-tags:
        required-cats:United States
        ignored-cats:Politicians, Presidents

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

@Krenair
Copy link
Contributor Author

Krenair commented Apr 6, 2017

Sure, I was just trying to stick to the existing config. I'll change it around to work like that.

@Krenair Krenair changed the title Attempt to support existing config for filtering by category. Allow filtering by category Apr 6, 2017
@Krenair
Copy link
Contributor Author

Krenair commented Apr 6, 2017

@benapetr
Copy link
Member

benapetr commented Apr 7, 2017

Because huggle3 is a rewrite of older version of huggle. Some of these were not implemented yet.

@benapetr
Copy link
Member

benapetr commented Apr 7, 2017

  • Some of these we probably don't want to implement. I will have a look how categories worked before, but if we have a chance to do it better way this time, I think we should use it :))

Copy link
Member

@benapetr benapetr left a 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 benapetr merged commit c8c8fe3 into huggle:master Apr 7, 2017
@Krenair
Copy link
Contributor Author

Krenair commented Apr 7, 2017

@benapetr: I don't think the GUI commit got merged?

@Krenair
Copy link
Contributor Author

Krenair commented Apr 7, 2017

nevermind, it got merged, had some issues with git. the way github merges commits together is a bit strange

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.

2 participants