Skip to content

Comments

Add API description to help users on Resource Page#22

Open
willy1989cv wants to merge 12 commits intostagingfrom
feat/enable-datastore
Open

Add API description to help users on Resource Page#22
willy1989cv wants to merge 12 commits intostagingfrom
feat/enable-datastore

Conversation

@willy1989cv
Copy link
Member

@willy1989cv willy1989cv commented Feb 19, 2026

Issue: https://github.com/datopian/City-of-Malmo-Open-Data-Portal/issues/34

Changes:

  • Enabled DataStoreExplorer for resources where datastore_active=True
  • Added an API button, that when clicked it opens a Modal showing exmples of codes for fetching data.
  • Added internationalization for components

@vercel
Copy link
Contributor

vercel bot commented Feb 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
malmo-data-portal Ready Ready Preview, Comment Feb 19, 2026 7:23pm

Request Review

@willy1989cv willy1989cv changed the base branch from main to staging February 19, 2026 13:33
@coderabbitai
Copy link

coderabbitai bot commented Feb 19, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/enable-datastore

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@willy1989cv willy1989cv changed the title [WIP] Enable datastore [WIP] Enable datastore features Feb 19, 2026
@willy1989cv willy1989cv changed the title [WIP] Enable datastore features Add API description to help users on Resource Page Feb 19, 2026
{
title: t("API.snippets.viaSql"),
value: `${base}/api/3/action/datastore_search_sql?sql=${
`SELECT * FROM "${id}" WHERE title LIKE '%jones%'`
Copy link
Member

Choose a reason for hiding this comment

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

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]

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