How to structure a MediaWiki and Cargo query in Visual Basic - mediawiki

I'm trying to pull some specific data from a wiki site; pcgamingwiki.
I would like to pull the save game data path from the site but I'm not understanding how to make the request properly. I also wanna state I'm not very knowledgeable about Visual Basic or even using C#, I did some VB back 5+ years ago and I remember bits a pieces.
What I want my app to do is using the steam game ID to search PCGamingWiki for the relevant game page ID, and then parse the save game location path of that game on that page.
I am using WikiClientLibrary with the Cargo extension support too.
This is the Visual Basic code that I have:
Async Sub main2()
Dim client As New WikiClientLibrary.Client.WikiClient()
Dim site As New WikiClientLibrary.Sites.WikiSite(client, "https://pcgamingwiki.com/w/api.php?")
Await site.Initialization
Dim page = New WikiClientLibrary.Pages.WikiPage(site, 3098)
Await page.RefreshAsync(WikiClientLibrary.Pages.PageQueryOptions.FetchContent)
RichTextBox1.AppendText(site.SiteInfo.SiteName)
RichTextBox1.AppendText(page.Content.Substring(0, 10000))
End Sub
And this Cargo query that gets the page ID from the Steam app ID
https://www.pcgamingwiki.com/w/api.php?action=cargoquery&tables=Infobox_game&fields=Infobox_game._pageID%3DPageID%2CInfobox_game.Steam_AppID&where=Infobox_game.Steam_AppID%20HOLDS%20"21000"&format=jsonfm
This is getting me the page information but I know there is a better way of getting the info.
Doing a wiki query for the sections gives me
{
"toclevel": 2,
"level": "3",
"line": "Save game data location",
"number": "3.2",
"index": "6",
"fromtitle": "Lego_Batman:_The_Videogame",
"byteoffset": 5842,
"anchor": "Save_game_data_location"
}
But the issue is that from what I could find is that I can only use the fromtitle and the index to get this information but on a different game page the fromtitle is different as it is the game name and the index changes as the content can be placed different on the page depending on the game.
I was hoping that I could use "number" as it seems they all are "3.2" or "anchor" as they all have "save_game_data_location" but I can't see how I could search by these identifiers. PCGamingWiki uses the Cargo extension but I'm not sure how I could make the right queries in visual basic to get the information I need or if there is another way of getting this content.
This is what the content on the page looks like
I'm just not sure how I convert the normal API queries cleanly and that Cargo query into Visual Basic code so any advice would be appreciated.

Related

Azure DevOps Server 2019 extension: How do I limit the work item data entry forms my custom page appears on?

I'm using Azure Devops Server 2019, update 1.1. My goal is to write an extension that presents a new page, but only on the user story work item data entry form and not the data entry form for a Task, Bug, Issues, etc. See screen shot
Here is the contributions section of my vss-extension.json (It's what produced the custom page in the screen shot above). I've read Extension manifest reference, but I can't find a setting related to limiting which form a new page appears on.
Does anyone know which area of the extensions architecture I need to work in to limit which forms on which a new page appears?
"contributions": [
{
"id": "sample-work-item-form-page",
"type": "ms.vss-work-web.work-item-form-page",
"description": "Custom work item form page",
"targets": [
"ms.vss-work-web.work-item-form"
],
"properties": {
"name": "Create Standard Tasks",
"uri": "workItemPage.html"
}
}
]
By reference to this doc: Extend the work item form, this web extension belongs to Azure Boards service, so it will appear in all work item pages as your mentioned doc: Extension manifest reference. Currently it is not documented to specify which work item type it appears in.
In addition, you could directly follow this doc: Customize the web layout for a work item type (Inheritance process) to add a custom page to the user story work item.

How to format a multi line string with triple quotes inside in JSON file?

I have markdown string to store in json file, so I am using multi line and so many things in the string. How can I store it in json object?
[
{ "title": "Title of Ebook",
"details": [
{
"head": "Introduction 1",
"data": """It’s important to follow trends in your field to ensure you’re staying current on standards and protocols and perhaps more so in the field of coding. Programmers of all specialties can benefit from following
#h this is a header
__italic__
industry-leading blogs to stay aware of the latest technologies.If you’re a coder of any sort you’ll want to subscribe to these useful programming blogs written by the top blogging coders.Each of these bloggers has made a name for themselves in the programming community by sharing relevant, high-quality information and tips for coders. They maintain their respective blogs well and keep current information posted on a regular basis.By following the best programming blogs you’ll find tips and shortcuts you may never have otherwise thought to try. Consider using an RSS feed reader through your phone or desktop browser to automatically download each new post from these top coding bloggers."""
}
}
]
When I will receive the string I will have the markdown style data from json.
Your object is not closed correctly. There are closing brackets missing.
Not sure if it answers your question but you can do it like this:
import 'dart:convert';
main(List<String> arguments) {
var json = [
{
"title": "Title of Ebook",
"details": [
{
"head": "Introduction 1",
"data":
"""It’s important to follow trends in your field to ensure you’re staying current on standards and protocols and perhaps more so in the field of coding. Programmers of all specialties can benefit from following
#h this is a header
__italic__
industry-leading blogs to stay aware of the latest technologies.If you’re a coder of any sort you’ll want to subscribe to these useful programming blogs written by the top blogging coders.Each of these bloggers has made a name for themselves in the programming community by sharing relevant, high-quality information and tips for coders. They maintain their respective blogs well and keep current information posted on a regular basis.By following the best programming blogs you’ll find tips and shortcuts you may never have otherwise thought to try. Consider using an RSS feed reader through your phone or desktop browser to automatically download each new post from these top coding bloggers."""
}
]
}
];
var encodedJson = jsonEncode(json);
print(encodedJson);
var details = json[0]['details'] as List;
print(details[0]['data']);
}

All metafields fetched via Shopify API got improper owner and all belong to "shop"

I got problem with shopify API and with data it provides. When i try to get list of all meta-fields with my app I end up with invalid data that tell all meta-fields are owned by shop (owner_id, owner_resource in JSON result). In shop I work with there is over 2000 meta-fields, created mostly by installed apps, that most certainly belong directly to resources like page, blog or product and most of them are most certain not associated directly with shop.
What is more strange when i use chrome plugins or free shopify app to edit meta-fields, that in data i recieve present as associated with shop, they are displayed as belonging to particular aspects of shop as it should be. Adding or deleting meta-field does not reflect on the data or count of meta-fields I get in way explained below.
So what I do first is getting count of metafields with following request, to later know how split data requests into pages.
/admin/metafields/count.json
then to get complete set of data i make series of requests like this
/admin/metafields.json?limit=200&page=1
...
As result i get (example data)
{ "id": 2488777, "namespace": "content_value", "key": "[default]3883205", "value": "There are no items in your cart. ", "value_type": "string", "description": "", "owner_id": 2174481, "created_at": "2014-12-30T20:23:56+01:00", "updated_at": "2014-12-30T20:33:56+01:00", "owner_resource": "shop" }
So my question is what wrong I do here making these requests and why i get invalid data, or it is maybe another "shopify thing" to get such behaviour. Can someone direct me how to get full valid list of meta-fields with rightfully associated owners? Is there any caching involved with metafields that could cause lack of update?
When you make a call to /admin/metafields.json without any query parameters then you will see the metafields that belong to the shop.
You can retrieve metafields that belong to another resource by making an authenticated GET request to a URL like this one: /admin/orders/3250063171/metafields.json
An alternate format for the URL is this: /admin/metafields.json?metafield[owner_id]=3250063171&metafield[owner_resource]=order

Slow responce whie parsing large JSON responce

I have developed a web application based on RESTFul design where the application takes JSON responce from JAVA based web service and displays in UI and it refreshes the data in every 5 seconds.
The application uses Bootstrap for UI design, Backbone and require.js for implementing an MVC stucture where JSON response is parsed as Backbone collection.
When an admin is using this application the JSON response size is too large(from 800 to 1100 objects).
This is where things get messy. As per my analysis the browser is taking up too much resource.So rest of the application is very slow. For eg if I try to open a modal, system freezes for some time and opens slowly thus giving a very poor user experience.
As per my analysis time is being taken in parsing the data
As a remedy I am removing all comments in code and trying to implement Gzip compression for JSON files/html/css/js.
Sample of the JSON object is pasted below
{
"name": "TEST",
"state": "Lunch",
"time": "00:00:09",
"manager": "TEST",
"site": "C",
"skill": "TEST",
"center": "TEST",
"teamLead": "TEST",
"workGroup": "TEST",
"lanId": "TEST",
"dbID": "TETS",
"loginId": "TEST",
"avgAcwTime": "nn",
"avgHandleTime": "nn",
"avgTalkTime": "nn",
"callsAnswered": "nn",
"dispSkill": "-",
"errCode": null,
"errDesc": null,
"avgAcwTimeth": "medium",
"avgHandleTimeth": "high",
"avgTalkTimeTh": "medium",
"callsAnsweredTh": "medium",
"stateTh": "high"
}
Pagenation can't be done due to some requirements.
Can any one suggest something to improve the perfomance
Also I am fetching data using Backbone.Collection.fetch()
getAgentMetric(){
this.metrices.fetch({
url : (isLocal) ? ('http://localhost:8080/jsons/agent.json') : (prev_this.url + '/agentstat'),
data: JSON.stringify(param),
type: "POST",
dataType: "JSON",
contentType: "application/json",
})
.done(function() {
// passing the datasource from ajax call
prev_this.agentLoacalSource.localdata = prev_this.metrices.toJSON();
});
timeout = setTimeout(_.bind(this.getAgentMetric, this), 5000);
},
Browsers can handle a heck of a lot more than a thousand objects without any strain, so I don't think it's the fact that you are simply requesting a large amount of data from the backend. It's more likely that some of your parsing or rendering code is slow.
A few possibilities without seeing any more of your code:
It really depends on what you're doing here, but I'm going to assume that you aren't using a templating library (hoganjs, handlebarsjs, etc). You should definitely look into using one as they speed things up quite a bit and make generating html a lot easier.
Are you running .append() for each individual model that you render? This will really slow things down. You should generate all of the html that needs to be generated, and then run .append() once.
What kind of event listeners are you adding for each model (if any)? Listing to scroll events without a debounce ends up slowing down your browser, especially if you add a bunch of them.
Unrelated to your slowness issues, there are a few problems that I see with this code:
Your timeout should be called from an .always() function in ajax to prevent concurrent requests from going out if for whatever reason a request is slow.
this.metrices.fetch(...)
.always(function() {
timeout = setTimeout(...);
}.bind(this));
Requests that are simply fetching data should use a GET instead of a POST request type. You can see https://stackoverflow.com/a/3477374/5780021 for more info about this.
I would recommend timing some of your code to see where the slowness is actually happening. This will allow you to actually determine how long things are taking between to points in code.
Firefox console.time
Chrome console.time
IE console.time

Can using the Documents List API cause files to appear on the change list?

My application is currently using the Document List API to track file and metadata changes using the Changelist. When we find a file has changed, we grab the metadata, the acl information, and the actual file. Lately we've found that we are getting a number a percentage of files that continually show up in the changelist every time we check.
After a bit of investigating, there is very little metadata that is changing in the file.
Here are examples from two different files that continually show up in the changelists.
Is there anyway I can avoid seeing these files over and over again? I have partially optimized to not download the files again, but it is still taking extra quite a bit of overhead to weed out false-positives from the changelist. Does anyone know if updating my app to use the Drive API will fix this issue?
Here is an example of what I'm seeing:
File 1 - Through the Documents List API
Initial Info
entry:etag=\""CkcaSU1LASt7ImBk"\"
id:...feeds/id/spreadsheet%3A0AgVqS9FfzZOCdGhZSVZ4UEtyT2tmRnZsR3lGNFBrVWc
published:2010-12-13T01:58:22.467Z
updated:2010-12-13T02:03:22.269Z
...
link:rel=\"thumbnail\" type=\"image/jpeg\" href=...?id=0AgVqS9FfzZOCdGhZSVZ4UEtyT2tmRnZsR3lGNFBrVWc&v=1&s=AMedNnoAAAAAUQHGlnP_b5jppjlFLN9OHRY5VSP2KZNR&sz=s220\"
...
/entry
Next Time I looked at the changelist
entry etag=\""CkUFR0sIQyt7ImBk"\"
id:...feeds/id/spreadsheet%3A0AgVqS9FfzZOCdGhZSVZ4UEtyT2tmRnZsR3lGNFBrVWc
published:2010-12-13T01:58:22.467Z
updated:2010-12-13T02:03:22.269Z
...
link:rel=\"thumbnail\" type=\"image/jpeg\" href=\"...?id=0AgVqS9FfzZOCdGhZSVZ4UEtyT2tmRnZsR3lGNFBrVWc&v=1&s=AMedNnoAAAAAUQMH4STQC7QSN1CJivPIl0U5KvMD8eKe&sz=s220\"
...
/entry
The only differences are the etag, updated time, and thumbnail image. The file itself did not change at all.
File 2 - This info I grabbed using the APIs explorer (using the DriveAPI 2 changes.get)
{
"kind": "drive#change",
"id": "21012",
"fileId": "0AgVqS9FfzZOCdGQyQUNjWkF0alVpNGd0WXNLMnpNU2c",
...
"thumbnailLink": ".../feeds/vt?gd=true&id=0AgVqS9FfzZOCdGQyQUNjWkF0alVpNGd0WXNLMnpNU2c&v=1&s=AMedNnoAAAAAUQlhSo3rF73K5WnN7E0qSR0uMhWEqM-t&sz=s220",
...
}
Ran through grabbing changes from the Documents List API, then checked the changelist again.
{
"kind": "drive#change",
"id": "21013",
"fileId": "0AgVqS9FfzZOCdGQyQUNjWkF0alVpNGd0WXNLMnpNU2c",
...
"thumbnailLink": ".../feeds/vt?gd=true&id=0AgVqS9FfzZOCdGQyQUNjWkF0alVpNGd0WXNLMnpNU2c&v=1&s=AMedNnoAAAAAUQlh69m8ZG_MzNujmmu80HN9XJ2jpG61&sz=s220",
...
}
In this case, the thumbnail link had again changed, and there was no longer a change with id 21012.