Add API description to help users on Resource Page#22
Add API description to help users on Resource Page#22willy1989cv wants to merge 12 commits intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| { | ||
| title: t("API.snippets.viaSql"), | ||
| value: `${base}/api/3/action/datastore_search_sql?sql=${ | ||
| `SELECT * FROM "${id}" WHERE title LIKE '%jones%'` |
There was a problem hiding this comment.
Looks good on the first two examples, but the third one needs to have the query term wrapped in single quotes.
This is the current one:https://ckan.city-of-malmo-staging.datopian.com/api/3/action/datastore_search_sql?sql=SELECT%20*%20FROM%20%226651a837-5208-410b-9554-47154e9fec5c%22%20WHERE%20title%20LIKE%20%27%jones%%27
And then with the single quotes added (around title):https://ckan.city-of-malmo-staging.datopian.com/api/3/action/datastore_search_sql?sql=SELECT%20*%20FROM%20%226651a837-5208-410b-9554-47154e9fec5c%22%20WHERE%20%27title%27%20LIKE%20%27%jones%%27
Also, can we extract a real value from the columns instead of title and jones? Ideally, copy/paste of any of these commands should work for the specific resource referenced.
You should be able to do this:
https://ckan.city-of-malmo-staging.datopian.com/api/3/action/datastore_search?id=5b512b5b-15bb-415d-82bf-e0b98ef3fa4a&limit=1
You'll get a single record back and can calculate maybe the middle index (length / 2 or similar to provide slightly more interesting example data when they copy/paste, instead of almost always being _id):
{
"help": "https://ckan.city-of-malmo-staging.datopian.com/api/3/action/help_show?name=datastore_search",
"success": true,
"result": {
"include_total": true,
"limit": 1,
"records_format": "objects",
"resource_id": "5b512b5b-15bb-415d-82bf-e0b98ef3fa4a",
"total_estimation_threshold": null,
"records": [
{
"_id": 1,
"ogc_fid": 1,
"anläggningsid": "6c7a97e7-d260-472a-b4f7-207d4f58ead7",
"Överordnadresursid": "d2b7f084-a660-4a5f-9868-6ced4c4574e2",
"anläggning": "Lindängens IP / Grusplan 1, 11-manna / 7-manna 2",
"typ": "7-manna grusplan",
"områden": "Fosie",
"hyralternativ": "Korttid",
"beskrivning": "",
"verksamheter": "Fotboll, Parkour",
"adress": "Tenorgatan 2A",
"postnr": "215 74",
"ort": "Malmö",
"latitud": 55.5549676038847,
"longitud": 13.0124350571888,
"wkb_geometry": {
"type": "Point",
"coordinates": [13.0124350571888, 55.5549676038847]
}
}
],
"fields": [
{
"id": "_id",
"type": "int"
},
{
"id": "ogc_fid",
"type": "int4"
},
{
"id": "anläggningsid",
"type": "varchar"
},
{
"id": "Överordnadresursid",
"type": "varchar"
},
{
"id": "anläggning",
"type": "varchar"
},
{
"id": "typ",
"type": "varchar"
},
{
"id": "områden",
"type": "varchar"
},
{
"id": "hyralternativ",
"type": "varchar"
},
{
"id": "beskrivning",
"type": "varchar"
},
{
"id": "verksamheter",
"type": "varchar"
},
{
"id": "adress",
"type": "varchar"
},
{
"id": "postnr",
"type": "varchar"
},
{
"id": "ort",
"type": "varchar"
},
{
"id": "latitud",
"type": "float8"
},
{
"id": "longitud",
"type": "float8"
},
{
"id": "wkb_geometry",
"type": "geometry"
}
],
"_links": {
"start": "/api/3/action/datastore_search?id=5b512b5b-15bb-415d-82bf-e0b98ef3fa4a&limit=1",
"next": "/api/3/action/datastore_search?id=5b512b5b-15bb-415d-82bf-e0b98ef3fa4a&limit=1&offset=1"
},
"total": 656,
"total_was_estimated": false
}
}
For example:
columnName = Object.keys(data.result.records[0])[index]
columnValue = data.result.records[0][columnName]
Issue: https://github.com/datopian/City-of-Malmo-Open-Data-Portal/issues/34
Changes:
datastore_active=True