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

Requesting support for query description #342

Closed
bsilverm opened this issue Jul 13, 2018 · 4 comments
Closed

Requesting support for query description #342

bsilverm opened this issue Jul 13, 2018 · 4 comments

Comments

@bsilverm
Copy link

bsilverm commented Jul 13, 2018

It would be great if the metadata file allowed you to enter a description for the query. We have a lot of pre-defined queries that can only be so descriptive by their name. It would be nice if an optional description could be included underneath the name within the UI, or on hover where it currently shows the SQL.

@simonw
Copy link
Owner

simonw commented Jul 13, 2018

That's a good idea. We already do this for tables - e.g. on https://fivethirtyeight.datasettes.com/fivethirtyeight-ac35616/most-common-name%2Fsurnames - so having it as an option for canned queries definitely makes sense.

@simonw
Copy link
Owner

simonw commented Jul 13, 2018

https://timezones-api.now.sh/-/metadata currently shows this:

{
    "databases": {
        "timezones": {
            "license": "ODbL",
            "license_url": "http://opendatacommons.org/licenses/odbl/",
            "queries": {
                "by_point": "select tzid\nfrom\n    timezones\nwhere\n    within(GeomFromText(\u0027POINT(\u0027 || :longitude || \u0027 \u0027 || :latitude || \u0027)\u0027), timezones.Geometry)\n    and rowid in (\n        SELECT pkid FROM idx_timezones_Geometry\n        where xmin \u003c :longitude\n        and xmax \u003e :longitude\n        and ymin \u003c :latitude\n        and ymax \u003e :latitude\n    )"
            },
            "source": "timezone-boundary-builder",
            "source_url": "https://github.com/evansiroky/timezone-boundary-builder",
            "tables": {
                "timezones": {
                    "license": "ODbL",
                    "license_url": "http://opendatacommons.org/licenses/odbl/",
                    "sortable_columns": [
                        "tzid"
                    ],
                    "source": "timezone-boundary-builder",
                    "source_url": "https://github.com/evansiroky/timezone-boundary-builder"
                }
            }
        }
    },
    "license": "ODbL",
    "license_url": "http://opendatacommons.org/licenses/odbl/",
    "source": "timezone-boundary-builder",
    "source_url": "https://github.com/evansiroky/timezone-boundary-builder",
    "title": "OpenStreetMap Time Zone Boundaries"
}

We could support the value part of the "queries" array optionally being a dictionary with the same set of metadata fields supported for a table, plus a new "sql" key to hold the SQL for the query.

@simonw
Copy link
Owner

simonw commented Jul 13, 2018

So it would look like this:

{
    "databases": {
        "timezones": {
            "license": "ODbL",
            "license_url": "http://opendatacommons.org/licenses/odbl/",
            "queries": {
                "by_point": {
                    "title": "Timezones by point",
                    "description": "Find the timezone for a latitude/longitude point",
                    "sql": "select tzid\nfrom\n    timezones\nwhere\n    within(GeomFromText('POINT(' || :longitude || ' ' || :latitude || ')'), timezones.Geometry)\n    and rowid in (\n        SELECT pkid FROM idx_timezones_Geometry\n        where xmin < :longitude\n        and xmax > :longitude\n        and ymin < :latitude\n        and ymax > :latitude\n    )"
                }
            }
        }
    }
}

@simonw simonw closed this as completed in 6e37f09 Jul 16, 2018
simonw added a commit to simonw/timezones-api that referenced this issue Jul 16, 2018
@simonw simonw added this to the Next release milestone Jul 16, 2018
@simonw simonw removed this from the Next release milestone Jul 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants