Skip to content

Commit

Permalink
Improved ?_extra=extras to show selected and available, refs #262
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Feb 8, 2023
1 parent 732285c commit 21568f9
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions datasette/views/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1850,11 +1850,17 @@ async def extra_request():

async def extra_extras():
"Available ?_extra= blocks"
return [{
"name": key[len("extra_"):],
"doc": fn.__doc__,
} for key, fn in registry._registry.items()
if key.startswith("extra_")]
return {
"available": [
{
"name": key[len("extra_") :],
"doc": fn.__doc__,
}
for key, fn in registry._registry.items()
if key.startswith("extra_")
],
"selected": list(extras),
}

registry = Registry(
extra_count,
Expand Down Expand Up @@ -1888,18 +1894,6 @@ async def extra_extras():

return Response.json(data)

return Response.json(
{
"debug": {

},
"sql": sql,
"next": next_value,
"rows": [dict(r) for r in results.rows],
},
default=repr,
)


async def _next_value_and_url(
datasette,
Expand Down

0 comments on commit 21568f9

Please sign in to comment.