-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
RecentChangesEnumerator not properly populating all results #90
Comments
Your code eventually sends the following request to TFWiki
You can see the response by opening the following link {
"warnings": {
"recentchanges": {
"*": "Unrecognized value for parameter 'rcprop': sha1"
}
},
"query": {
"recentchanges": [
{
"tags": []
},
{
"tags": []
},
{
"tags": []
},
{
"tags": []
},
{
"tags": []
},
{
"tags": []
},
{
"tags": []
},
{
"tags": []
},
{
"tags": []
},
{
"tags": []
},
{
"tags": []
},
{
"tags": []
},
{
"tags": []
},
{
"tags": []
}
]
}
} This response is abnormal. especially, there is no other fields except Actually, if you remove the {"warnings":{"recentchanges":{"*":"Unrecognized value for parameter 'rcprop': sha1"}},"query":{"recentchanges":[]}} |
So what you can do here is
private IEnumerable<KeyValuePair<string, object?>> EnumParams(bool isList)
=> base.EnumParams(isList).Select(p => p.Key == "rvprop" ? new KeyValuePair<string, object?>(p.Key, ((string)p.Value).Replace("|tags", "")) : p); |
To furtherly prove this, try the code below: .NET Fiddle using System;
using System.Linq;
using WikiClientLibrary.Client;
using WikiClientLibrary.Sites;
using WikiClientLibrary.Generators;
using var client = new WikiClient();
var site = new WikiSite(client, "https://tfwiki.net/mediawiki/api.php");
await site.Initialization;
Console.WriteLine(site.SiteInfo + " " + site.SiteInfo.Version);
var generator = new RecentChangesGenerator(site)
{
PaginationSize = 50,
EndTime = DateTime.Parse("13:36, 30 October 2021"),
TypeFilters = RecentChangesFilterTypes.Log
};
Console.WriteLine("Server side log filtering");
var items = await generator.EnumItemsAsync().ToListAsync();
Console.WriteLine("{0} items:", items.Count);
foreach (var i in items) Console.WriteLine(i);
Console.WriteLine("Client side log filtering");
generator.TypeFilters = RecentChangesFilterTypes.All;
items = await generator.EnumItemsAsync().Where(i => i.Type == RecentChangesType.Log).ToListAsync();
Console.WriteLine("{0} items:", items.Count);
foreach (var i in items) Console.WriteLine(i); The output is
It seems that the issue won't manifest if you are listing everything instead of listing logs on the server-side. |
It seems to be specifically the sha tag (or maybe tags in general) being incompatible with the API. This query returns results with log filtering: |
And now I see this isn't even what I want to query since recent changes doesn't appear to include the user creation log entries, despite those log events appearing on the recent changes page. I don't see a generator for log events so I'm guessing I need to write my own generator and/or use InvokeMediaWikiApiAsync to query that list. Would the same apply to retrieving the allusers list as well? |
Yet further API testing shows that I can get user creation logs from the RecentChanges API so long as you don't ask it to populate loginfo. This causes it to filter out some types of logs, presumably because they don't have those fields. With this in mind, I was going to adopt your suggestion of deriving a class from RecentChangesGenerator and override EnumParams...except that EnumParams is a private method and can't be overriden. Would you be open to changing that or do you have another suggestion? The question about retrieving users still stands as well. |
I used the following code to get log entries via the RecentChangesEnumerator:
This is results in two items being returned, but neither have any of their properties populated. Broader searches seem to return a mix of populated and unpopulated results. As usual I'm working with TFWiki.net which is on MW 1.19.
The text was updated successfully, but these errors were encountered: