mirror of
https://github.com/discourse/discourse.git
synced 2026-08-06 04:02:30 +08:00
Small updates to data explorer: For `/new` (AI query creation) - Auto-runs the generated query and shows the result first, mirroring /edit - New admin-only POST queries/preview endpoint runs unsaved SQL so results can be previewed before creating a query - Chart / table / SQL segmented control similar to /edit - SQL with a resizable grippie - "Save query" is now the primary button - added a "Run" button. - Saving transitions to /edit and auto-runs (?run=true). - More breathing room between SQL and the name/description fields. For `/edit` - Disables Run / Save-and-run / Undo / Help / Delete while a query is running or AI is generating. Charts & tables (shared QueryResult) - Smarter default view: falls back to table when a chart would silently drop columns (e.g. user / username / reason / sum) pure-numeric series still chart. - long tables now cap at chart height with a chevron expand button, so action buttons stay reachable (this was done before) - /g/x/reports also have memory over which option (chart/table) was chosen before Copy (i18n) - "Re-generate" to "Update prompt".
55 lines
2.5 KiB
Ruby
Vendored
55 lines
2.5 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
DiscourseDataExplorer::Engine.routes.draw do
|
|
root to: "query#index"
|
|
get "queries" => "query#index"
|
|
get "queries/new" => "query#index"
|
|
get "queries/:id" => "query#show", :constraints => { id: /-?\d+/ }
|
|
|
|
scope "/", defaults: { format: :json } do
|
|
get "schema" => "query#schema"
|
|
get "groups" => "query#groups"
|
|
post "queries/generate" => "query#generate_with_ai"
|
|
post "queries/preview" => "query#preview"
|
|
post "queries" => "query#create"
|
|
put "queries/:id" => "query#update"
|
|
delete "queries/:id" => "query#destroy"
|
|
post "queries/:id/run" => "query#run", :constraints => { format: /(json|csv)/ }
|
|
end
|
|
end
|
|
|
|
Discourse::Application.routes.draw do
|
|
get "/g/:group_name/reports" => "discourse_data_explorer/query#group_reports_index"
|
|
get "/g/:group_name/reports/:id" => "discourse_data_explorer/query#group_reports_show"
|
|
post "/g/:group_name/reports/:id/run" => "discourse_data_explorer/query#group_reports_run"
|
|
|
|
# Public API to fetch query results via GET with permission checks
|
|
get "/data-explorer/queries/:id/run" => "discourse_data_explorer/query#public_run",
|
|
:constraints => {
|
|
format: /(json|csv)/,
|
|
}
|
|
|
|
mount DiscourseDataExplorer::Engine, at: "/admin/plugins/discourse-data-explorer"
|
|
get "/admin/plugins/explorer" => redirect("/admin/plugins/discourse-data-explorer")
|
|
get "/admin/plugins/explorer/queries" =>
|
|
redirect("/admin/plugins/discourse-data-explorer/queries")
|
|
get "/admin/plugins/explorer/queries/:id" =>
|
|
redirect("/admin/plugins/discourse-data-explorer/queries/%{id}")
|
|
|
|
# Legacy /admin/plugins/explorer/ API routes - route directly to controller
|
|
# since redirects don't preserve POST/PUT/DELETE request bodies
|
|
scope "/", defaults: { format: :json } do
|
|
get "/admin/plugins/explorer/schema" => "discourse_data_explorer/query#schema"
|
|
get "/admin/plugins/explorer/groups" => "discourse_data_explorer/query#groups"
|
|
post "/admin/plugins/explorer/queries/generate" =>
|
|
"discourse_data_explorer/query#generate_with_ai"
|
|
post "/admin/plugins/explorer/queries/preview" => "discourse_data_explorer/query#preview"
|
|
post "/admin/plugins/explorer/queries" => "discourse_data_explorer/query#create"
|
|
put "/admin/plugins/explorer/queries/:id" => "discourse_data_explorer/query#update"
|
|
delete "/admin/plugins/explorer/queries/:id" => "discourse_data_explorer/query#destroy"
|
|
post "/admin/plugins/explorer/queries/:id/run" => "discourse_data_explorer/query#run",
|
|
:constraints => {
|
|
format: /(json|csv)/,
|
|
}
|
|
end
|
|
end
|