Skip to content

A platform for community discussion. Free, open, simple.

DEV: Load Data Explorer queries via JSON:API and WarpDrive (#44969)

Jarek Radosz29e48ce19493
diff --git a/frontend/discourse/app/data/builders/json-api.js b/frontend/discourse/app/data/builders/json-api.js
new file mode 100644
index 00000000000..d2d1878678e
--- /dev/null
+++ b/frontend/discourse/app/data/builders/json-api.js
@@ -0,0 +1,13 @@
+import { filterEmpty } from "@warp-drive/utilities";
+import { query as warpQuery } from "@warp-drive/utilities/json-api";
+
+// Exposed here because plugins and themes can't import npm modules directly.
+export { filterEmpty };
+
+// JsonApiKit takes list parameters in bracket form (`include[]=…`).
+export function query(type, params, options = {}) {
+ return warpQuery(type, params, {
+ urlParamsSettings: { arrayFormat: "bracket" },
+ ...options,
+ });
+}
diff --git a/frontend/discourse/app/data/handlers/json-api.js b/frontend/discourse/app/data/handlers/json-api.js
new file mode 100644
index 00000000000..1065e32559a
--- /dev/null
+++ b/frontend/discourse/app/data/handlers/json-api.js
@@ -0,0 +1,28 @@
+import { ajax } from "discourse/lib/ajax";
+import { withoutPrefix } from "discourse/lib/get-url";
+
+export const JSON_API_VERSION = "2026-08-31";
+
+// Matched by URL, not by a request option: paging links (`document.next()`)
+// issue a bare `{ url, method }` request.
+function isJsonApiUrl(url) {
+ return withoutPrefix(
+ new URL(url, window.location.origin).pathname
+ ).startsWith("/api/");
+}
+
+const jsonApiHandler = {
+ async request(context, next) {
+ const request = context.request;
+ if (!request.url || !isJsonApiUrl(request.url)) {
+ return next(request);
+ }
+
+ return ajax(request.url, {
+ type: request.method,
+ headers: { "Api-Version": JSON_API_VERSION },
+ });
+ },
+};
+
+export default jsonApiHandler;
diff --git a/frontend/discourse/app/data/schemas/helpers.js b/frontend/discourse/app/data/schemas/helpers.js
index 689d6f8d3b7..efd93c6a901 100644
--- a/frontend/discourse/app/data/schemas/helpers.js
+++ b/frontend/discourse/app/data/schemas/helpers.js
@@ -1,11 +1,28 @@
-// Schemas annotate their export with `@type {LegacyResourceSchema}` so the
-// emitted `.d.ts` doesn't anchor through pnpm's `.pnpm/...` path (TS2883).
+/**
+ * @import {
+ * LegacyAttributeField,
+ * LegacyBelongsToField,
+ * LegacyHasManyField,
+ * } from "@warp-drive/core/types/schema/fields"
+ */
+
+// Schemas annotate their export as `LegacyResourceSchema` so the emitted
+// `.d.ts` doesn't anchor through pnpm's `.pnpm/...` path (TS2883).
export { withDefaults } from "@warp-drive/legacy/model/migration-support";
+/**
+ * @param {...string} names
+ * @returns {LegacyAttributeField[]}
+ */
export function attrs(...names) {
return names.map((name) => ({ kind: "attribute", name }));
}
+/**
+ * @param {string} name
+ * @param {string} type
+ * @returns {LegacyBelongsToField}
+ */
export function belongsTo(name, type) {
return {
kind: "belongsTo",
@@ -14,3 +31,12 @@ export function belongsTo(name, type) {
options: { async: false, inverse: null },
};
}
+
+/**
+ * @param {string} name
+ * @param {string} type
+ * @returns {LegacyHasManyField}
+ */
+export function hasMany(name, type) {
+ return { ...belongsTo(name, type), kind: "hasMany" };
+}
diff --git a/frontend/discourse/app/data/schemas/index.js b/frontend/discourse/app/data/schemas/index.js
index 4b2e53bc7b2..c548ad33fd3 100644
--- a/frontend/discourse/app/data/schemas/index.js
+++ b/frontend/discourse/app/data/schemas/index.js
@@ -3,6 +3,8 @@ import { BadgeSchema } from "./badge.js";
import { BadgeGroupingSchema } from "./badge-grouping.js";
import { BadgeTypeSchema } from "./badge-type.js";
import { BookmarkSchema } from "./bookmark.js";
+import { GroupsSchema } from "./json-api/groups.ts";
+import { UsersSchema } from "./json-api/users.ts";
import { TagSchema } from "./tag.js";
import { TagGroupSchema } from "./tag-group.js";
import { TagInfoSchema } from "./tag-info.js";
@@ -18,6 +20,7 @@ export const schemas = [
BadgeTypeSchema,
BadgeGroupingSchema,
BookmarkSchema,
+ GroupsSchema,
TagSchema,
TagGroupSchema,
TagInfoSchema,
@@ -25,4 +28,5 @@ export const schemas = [
TagSettingsSchema,
TopicDetailsSchema,
UserBadgeSchema,
+ UsersSchema,
];
diff --git a/frontend/discourse/app/data/schemas/json-api/groups.ts b/frontend/discourse/app/data/schemas/json-api/groups.ts
new file mode 100644
index 00000000000..57cdf3fcc6b
--- /dev/null
+++ b/frontend/discourse/app/data/schemas/json-api/groups.ts
@@ -0,0 +1,8 @@
+import type { LegacyResourceSchema } from "@warp-drive/core/types/schema/fields";
+import { attrs, withDefaults } from "../helpers.js";
+
+// Mirrors `GroupResource` (app/resources/group_resource.rb).
+export const GroupsSchema: LegacyResourceSchema = withDefaults({
+ type: "groups",
+ fields: attrs("name"),
+});
diff --git a/frontend/discourse/app/data/schemas/json-api/users.ts b/frontend/discourse/app/data/schemas/json-api/users.ts
new file mode 100644
index 00000000000..20ff9c65b5c
--- /dev/null
+++ b/frontend/discourse/app/data/schemas/json-api/users.ts
@@ -0,0 +1,8 @@
+import type { LegacyResourceSchema } from "@warp-drive/core/types/schema/fields";
+import { attrs, withDefaults } from "../helpers.js";
+
+// Mirrors `UserResource` (app/resources/user_resource.rb).
+export const UsersSchema: LegacyResourceSchema = withDefaults({
+ type: "users",
+ fields: attrs("username", "avatarTemplate"),
+});
diff --git a/frontend/discourse/app/lib/ajax-error.js b/frontend/discourse/app/lib/ajax-error.js
index 08278a167a1..92ee33e2e7b 100644
--- a/frontend/discourse/app/lib/ajax-error.js
+++ b/frontend/discourse/app/lib/ajax-error.js
@@ -57,13 +57,16 @@ export function extractErrorInfo(
html = true;
}
- if (parsedJSON.errors?.length > 1) {
+ // JSON:API error objects carry their message in `detail`/`title`.
+ const errors = parsedJSON.errors?.map((e) => e?.detail ?? e?.title ?? e);
+
+ if (errors?.length > 1) {
parsedError = i18n("multiple_errors", {
- errors: parsedJSON.errors.map((e, i) => `${i + 1}) ${e}`).join(" "),
+ errors: errors.map((e, i) => `${i + 1}) ${e}`).join(" "),
});
- } else if (parsedJSON.errors?.length > 0) {
+ } else if (errors?.length > 0) {
parsedError = i18n("generic_error_with_reason", {
- error: parsedJSON.errors[0],
+ error: errors[0],
});
} else if (parsedJSON.error) {
parsedError = parsedJSON.error;
diff --git a/frontend/discourse/app/services/warp-store.js b/frontend/discourse/app/services/warp-store.js
index e78b3dfc2f8..a2f94536998 100644
--- a/frontend/discourse/app/services/warp-store.js
+++ b/frontend/discourse/app/services/warp-store.js
@@ -1,13 +1,14 @@
import { JSONAPICache } from "@warp-drive/json-api";
import { useLegacyStore } from "@warp-drive/legacy";
import discourseRestHandler from "discourse/data/handlers/discourse-rest";
+import jsonApiHandler from "discourse/data/handlers/json-api";
import { schemas } from "discourse/data/schemas";
-// `linksMode: true` skips the LegacyNetworkHandler so our handler is the
+// `linksMode: true` skips the LegacyNetworkHandler so our handlers are the
// sole network layer (routes through Discourse's `ajax()` helper).
export default class WarpStore extends useLegacyStore({
cache: JSONAPICache,
schemas,
- handlers: [discourseRestHandler],
+ handlers: [jsonApiHandler, discourseRestHandler],
linksMode: true,
}) {}
diff --git a/frontend/discourse/tests/unit/lib/ajax-error-test.js b/frontend/discourse/tests/unit/lib/ajax-error-test.js
index 38c723027ff..bc135e0b275 100644
--- a/frontend/discourse/tests/unit/lib/ajax-error-test.js
+++ b/frontend/discourse/tests/unit/lib/ajax-error-test.js
@@ -10,6 +10,7 @@ import {
import getURL from "discourse/lib/get-url";
import pretender, {
middlewareRateLimit,
+ response,
TOO_MANY_REQUESTS,
} from "discourse/tests/helpers/create-pretender";
import { i18n } from "discourse-i18n";
@@ -155,4 +156,20 @@ module("Unit | Lib | ajax-error", function (hooks) {
"prefers the localized message from the server"
);
});
+
+ test("extractError reads the detail of a JSON:API error object", async function (assert) {
+ pretender.get("/json-api-forbidden", () =>
+ response(403, {
+ errors: [{ title: "Forbidden", detail: "Not allowed." }],
+ })
+ );
+
+ assert.strictEqual(
+ extractError(await ajaxError("/json-api-forbidden")),
+ i18n("generic_error_with_reason", {
+ error: "Not allowed.",
+ }),
+ "shows the error detail"
+ );
+ });
});
diff --git a/plugins/chat/spec/system/plugin_admin_interface_compatibility_spec.rb b/plugins/chat/spec/system/plugin_admin_interface_compatibility_spec.rb
index 4ef52fc51b3..10bf36d5f25 100644
--- a/plugins/chat/spec/system/plugin_admin_interface_compatibility_spec.rb
+++ b/plugins/chat/spec/system/plugin_admin_interface_compatibility_spec.rb
@@ -2,6 +2,8 @@
RSpec.describe "Plugin admin interface compatibility" do
fab!(:current_user, :admin)
+ # Tests don't seed the bundled queries, and an empty list renders no table.
+ fab!(:query)
before do
sign_in(current_user)
diff --git a/plugins/discourse-data-explorer/admin/assets/javascripts/admin/templates/admin-plugins/show/explorer/index.gjs b/plugins/discourse-data-explorer/admin/assets/javascripts/admin/templates/admin-plugins/show/explorer/index.gjs
index 4049c406605..6d1126e33bf 100644
--- a/plugins/discourse-data-explorer/admin/assets/javascripts/admin/templates/admin-plugins/show/explorer/index.gjs
+++ b/plugins/discourse-data-explorer/admin/assets/javascripts/admin/templates/admin-plugins/show/explorer/index.gjs
@@ -1,4 +1,4 @@
-import { fn } from "@ember/helper";
+import { fn, hash } from "@ember/helper";
import { on } from "@ember/modifier";
import { LinkTo } from "@ember/routing";
import DConditionalLoadingSpinner from "discourse/ui-kit/d-conditional-loading-spinner";
@@ -10,9 +10,9 @@ import DPickFilesButton from "discourse/ui-kit/d-pick-files-button";
import DTableHeaderToggle from "discourse/ui-kit/d-table-header-toggle";
import DUserLink from "discourse/ui-kit/d-user-link";
import dAgeWithTooltip from "discourse/ui-kit/helpers/d-age-with-tooltip";
-import dAvatar from "discourse/ui-kit/helpers/d-avatar";
+import dBoundAvatarTemplate from "discourse/ui-kit/helpers/d-bound-avatar-template";
import { i18n } from "discourse-i18n";
-import ShareReport from "discourse/plugins/discourse-data-explorer/discourse/components/share-report";
+import QueryGroups from "discourse/plugins/discourse-data-explorer/discourse/components/query-groups";
export default <template>
<div class="admin-detail">
@@ -38,7 +38,7 @@ export default <template>
<DFilterControls
@additionalFiltersActive={{@controller.hasTagFilter}}
- @array={{@controller.model.content}}
+ @array={{@controller.queries}}
@initialTextFilter={{@controller.textFilter}}
@inputPlaceholder={{i18n "explorer.search_placeholder"}}
@loading={{@controller.searchLoading}}
@@ -60,10 +60,14 @@ export default <template>
</:additionalFilters>
<:content as |filteredQueries|>
- {{#if @controller.model.content.length}}
+ {{#if @controller.queries.length}}
<DConditionalLoadingSpinner @condition={{@controller.loading}} />
- <DLoadMore @action={{@controller.loadMore}}>
+ <DLoadMore
+ @action={{@controller.loadMore}}
+ @enabled={{@controller.canLoadMore}}
+ @isLoading={{@controller.loadingMore}}
+ >
<div class="container discourse-data-explorer-query-list">
<table class="d-table recent-queries">
<thead class="d-table__header">
@@ -144,9 +148,13 @@ export default <template>
{{#if query.user}}
<DUserLink
class="query-created-by__link"
- @user={{query.user}}
+ @username={{query.user.username}}
>
- {{dAvatar query.user imageSize="tiny"}}
+ {{dBoundAvatarTemplate
+ query.user.avatarTemplate
+ "tiny"
+ (hash title=query.user.username)
+ }}
<span>{{query.user.username}}</span>
</DUserLink>
{{/if}}
@@ -156,28 +164,16 @@ export default <template>
{{i18n "explorer.query_groups"}}
</div>
<div class="group-names">
- {{#each query.group_names as |group|}}
- <ShareReport @group={{group}} @query={{query}} />
- {{/each}}
- {{#unless query.group_names.length}}
- -
- {{/unless}}
+ <QueryGroups @query={{query}} />
</div>
</td>
<td class="d-table__cell --detail query-created-at">
<div class="d-table__mobile-label">
{{i18n "explorer.query_time"}}
</div>
- {{#if query.last_run_at}}
+ {{#if query.lastRunAt}}
<span>
- {{dAgeWithTooltip
- query.last_run_at
- format="medium"
- }}
- </span>
- {{else if query.created_at}}
- <span>
- {{dAgeWithTooltip query.created_at format="medium"}}
+ {{dAgeWithTooltip query.lastRunAt format="medium"}}
</span>
{{else}}
-
@@ -191,7 +187,7 @@ export default <template>
@route="adminPlugins.show.explorer.edit"
{{on "click" @controller.scrollTop}}
>
- {{#if query.is_default}}
+ {{#if query.isDefault}}
{{i18n "explorer.view_query"}}
{{else}}
{{i18n "edit"}}
@@ -206,9 +202,7 @@ export default <template>
</div>
</DLoadMore>
- <DConditionalLoadingSpinner
- @condition={{@controller.model.loadingMore}}
- />
+ <DConditionalLoadingSpinner @condition={{@controller.loadingMore}} />
{{/if}}
</:content>
</DFilterControls>
diff --git a/plugins/discourse-data-explorer/assets/javascripts/discourse/components/query-groups.gjs b/plugins/discourse-data-explorer/assets/javascripts/discourse/components/query-groups.gjs
new file mode 100644
index 00000000000..f4daa417868
--- /dev/null
+++ b/plugins/discourse-data-explorer/assets/javascripts/discourse/components/query-groups.gjs
@@ -0,0 +1,50 @@
+import Component from "@glimmer/component";
+import { tracked } from "@glimmer/tracking";
+import { service } from "@ember/service";
+import { popupAjaxError } from "discourse/lib/ajax-error";
+import ShareReport from "./share-report.gjs";
+
+export default class QueryGroups extends Component {
+ @service warpStore;
+
+ @tracked allGroups;
+
+ constructor() {
+ super(...arguments);
+
+ // List responses cap each query's groups; `next` marks a truncated list.
+ const links = this.args.query.hasMany("groups").links();
+ if (links?.next) {
+ this.#loadAll(links.related);
+ }
+ }
+
+ get groups() {
+ return this.allGroups ?? this.args.query.groups;
+ }
+
+ async #loadAll(related) {
+ try {
+ let { content: page } = await this.warpStore.request({ url: related });
+ const groups = [...page.data];
+ while (page.links?.next) {
+ page = await page.next();
+ groups.push(...page.data);
+ }
+
+ if (!this.isDestroying) {
+ this.allGroups = groups;
+ }
+ } catch (e) {
+ popupAjaxError(e);
+ }
+ }
+
+ <template>
+ {{#each this.groups as |group|}}
+ <ShareReport @group={{group.name}} @query={{@query}} />
+ {{else}}
+ -
+ {{/each}}
+ </template>
+}
diff --git a/plugins/discourse-data-explorer/assets/javascripts/discourse/controllers/admin-plugins/show/explorer/index.js b/plugins/discourse-data-explorer/assets/javascripts/discourse/controllers/admin-plugins/show/explorer/index.js
index a15d9644423..3329a6e3953 100644
--- a/plugins/discourse-data-explorer/assets/javascripts/discourse/controllers/admin-plugins/show/explorer/index.js
+++ b/plugins/discourse-data-explorer/assets/javascripts/discourse/controllers/admin-plugins/show/explorer/index.js
@@ -3,7 +3,6 @@ import Controller from "@ember/controller";
import { action } from "@ember/object";
import { service } from "@ember/service";
import { Promise } from "rsvp";
-import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
import discourseDebounce from "discourse/lib/debounce";
import { bind } from "discourse/lib/decorators";
@@ -11,47 +10,43 @@ import { INPUT_DELAY } from "discourse/lib/environment";
import getURL from "discourse/lib/get-url";
import { applyQueryParams } from "discourse/lib/url";
import { i18n } from "discourse-i18n";
+import { findQueries } from "discourse/plugins/discourse-data-explorer/discourse/data/builders/queries";
export default class PluginsExplorerController extends Controller {
@service dialog;
@service router;
@service store;
+ @service warpStore;
@tracked sortByProperty = "last_run_at";
@tracked sortDescending = true;
- @tracked params;
@tracked loading = false;
@tracked searchLoading = false;
@tracked queryTags = [];
@tracked tags = "";
+ @tracked pages = [];
+ @tracked loadingMore = false;
queryParams = ["id", "tags"];
- explain = false;
acceptedImportFileTypes = ["application/json"];
- order = null;
- form = null;
#latestQueryRequest;
_currentFilter = "";
- get parsedParams() {
- return this.params ? JSON.parse(this.params) : null;
+ get fetchParams() {
+ return {
+ search: this._currentFilter,
+ tags: this.currentTags,
+ sort: this.sortByProperty,
+ descending: this.sortDescending,
+ };
}
- get fetchParams() {
- const params = {};
- if (this._currentFilter) {
- params.filter = this._currentFilter;
- }
- if (this.currentTags.length) {
- params.tags = this.currentTags.join(",");
- }
- if (this.sortByProperty !== "last_run_at") {
- params.order = this.sortByProperty;
- }
- if (!this.sortDescending) {
- params.ascending = "true";
- }
- return params;
+ get queries() {
+ return this.pages.flatMap((page) => page.data);
+ }
+
+ get canLoadMore() {
+ return !!this.pages.at(-1)?.links?.next;
}
get hasTagFilter() {
@@ -70,9 +65,11 @@ export default class PluginsExplorerController extends Controller {
return this.currentTags.map((tag) => ({ id: tag, name: tag }));
}
- addCreatedRecord(record) {
- this.model.content.push(record);
- this.router.transitionTo("adminPlugins.show.explorer.edit", record.id);
+ reset(document, queryTags) {
+ this.#latestQueryRequest = null;
+ this.searchLoading = false;
+ this.pages = [document];
+ this.queryTags = queryTags;
}
@bind
@@ -86,7 +83,7 @@ export default class PluginsExplorerController extends Controller {
this.loading = true;
const file = files[0];
const record = await this._importQuery(file);
- this.addCreatedRecord(record);
+ this.router.transitionTo("adminPlugins.show.explorer.edit", record.id);
} catch (e) {
if (e.jqXHR) {
popupAjaxError(e);
@@ -171,9 +168,22 @@ export default class PluginsExplorerController extends Controller {
@action
async loadMore() {
- const loadedMore = await this.model?.loadMore();
- if (loadedMore) {
- this._setGroupNames(this.model.content);
+ if (this.loadingMore || !this.canLoadMore) {
+ return;
+ }
+
+ const last = this.pages.at(-1);
+ this.loadingMore = true;
+ try {
+ const page = await last.next();
+ // Drop the page if the list was replaced meanwhile.
+ if (this.pages.at(-1) === last) {
+ this.pages = [...this.pages, page];
+ }
+ } catch (e) {
+ popupAjaxError(e);
+ } finally {
+ this.loadingMore = false;
}
}
@@ -208,31 +218,18 @@ export default class PluginsExplorerController extends Controller {
}
async _fetchQueries() {
- const model = this.model;
const request = (this.#latestQueryRequest = {});
try {
- const result = await ajax(
- "/admin/plugins/discourse-data-explorer/queries.json",
- { data: this.fetchParams }
+ const { content } = await this.warpStore.request(
+ findQueries(this.fetchParams)
);
- if (request !== this.#latestQueryRequest || model !== this.model) {
- return;
+ if (request === this.#latestQueryRequest) {
+ this.pages = [content];
}
-
- const queries = result.queries.map((q) =>
- this.store.createRecord("query", q)
- );
-
- model.content.splice(0, model.content.length, ...queries);
- model.totalRows = result.total_rows_queries || queries.length;
- model.loadMoreUrl = result.load_more_queries || null;
- this.queryTags = result.extras?.tags ?? this.queryTags;
-
- this._setGroupNames(queries);
} catch (e) {
- if (request === this.#latestQueryRequest && model === this.model) {
+ if (request === this.#latestQueryRequest) {
popupAjaxError(e);
}
} finally {
@@ -241,20 +238,4 @@ export default class PluginsExplorerController extends Controller {
}
}
}
-
- _setGroupNames(queries) {
- if (!this.groups) {
- return;
- }
- const groupNames = {};
- this.groups.forEach((g) => {
- groupNames[g.id] = g.name;
- });
- queries.forEach((query) => {
- query.set(
- "group_names",
- (query.group_ids || []).map((id) => groupNames[id])
- );
- });
- }
}
diff --git a/plugins/discourse-data-explorer/assets/javascripts/discourse/data/builders/queries.js b/plugins/discourse-data-explorer/assets/javascripts/discourse/data/builders/queries.js
new file mode 100644
index 00000000000..58fb6d7b04b
--- /dev/null
+++ b/plugins/discourse-data-explorer/assets/javascripts/discourse/data/builders/queries.js
@@ -0,0 +1,20 @@
+import { filterEmpty, query } from "discourse/data/builders/json-api";
+
+const SORT_FIELDS = {
+ name: "name",
+ username: "user.username",
+ last_run_at: "lastRunAt",
+};
+
+export function findQueries({ search, tags, sort, descending }) {
+ return query(
+ "queries",
+ filterEmpty({
+ include: ["user", "groups"],
+ sort: `${descending ? "-" : ""}${SORT_FIELDS[sort]}`,
+ "filter[search]": search,
+ "filter[tag]": tags,
+ }),
+ { namespace: "api/data-explorer" }
+ );
+}
diff --git a/plugins/discourse-data-explorer/assets/javascripts/discourse/data/schemas/queries.js b/plugins/discourse-data-explorer/assets/javascripts/discourse/data/schemas/queries.js
new file mode 100644
index 00000000000..ed5029e8b3f
--- /dev/null
+++ b/plugins/discourse-data-explorer/assets/javascripts/discourse/data/schemas/queries.js
@@ -0,0 +1,29 @@
+import {
+ attrs,
+ belongsTo,
+ hasMany,
+ withDefaults,
+} from "discourse/data/schemas/helpers";
+
+// Mirrors `QueryResource` (app/resources/discourse_data_explorer/query_resource.rb).
+/** @type {import("@warp-drive/core/types/schema/fields").LegacyResourceSchema} */
+export const QueriesSchema = withDefaults({
+ type: "queries",
+ fields: [
+ ...attrs(
+ "name",
+ "description",
+ "sql",
+ "paramInfo",
+ "isDefault",
+ "createdAt",
+ "lastRunAt",
+ "tags",
+ "automaticTags",
+ "dashboardMountable",
+ "dashboardMounted"
+ ),
+ belongsTo("user", "users"),
+ hasMany("groups", "groups"),
+ ],
+});
diff --git a/plugins/discourse-data-explorer/assets/javascripts/discourse/initializers/initialize-data-explorer.js b/plugins/discourse-data-explorer/assets/javascripts/discourse/initializers/initialize-data-explorer.js
index dfceb42861e..cfe71e02d7a 100644
--- a/plugins/discourse-data-explorer/assets/javascripts/discourse/initializers/initialize-data-explorer.js
+++ b/plugins/discourse-data-explorer/assets/javascripts/discourse/initializers/initialize-data-explorer.js
@@ -1,6 +1,14 @@
+import { QueriesSchema } from "../data/schemas/queries.js";
+
export default {
name: "initialize-data-explorer",
initialize(container) {
container.lookup("service:store").addPluralization("query", "queries");
+
+ if (container.lookup("service:current-user")?.admin) {
+ container
+ .lookup("service:warp-store")
+ .schema.registerResources([QueriesSchema]);
+ }
},
};
diff --git a/plugins/discourse-data-explorer/assets/javascripts/discourse/routes/admin-plugins/show/explorer/index.js b/plugins/discourse-data-explorer/assets/javascripts/discourse/routes/admin-plugins/show/explorer/index.js
index e8d5d0c7fd1..40de0742bdf 100644
--- a/plugins/discourse-data-explorer/assets/javascripts/discourse/routes/admin-plugins/show/explorer/index.js
+++ b/plugins/discourse-data-explorer/assets/javascripts/discourse/routes/admin-plugins/show/explorer/index.js
@@ -1,9 +1,11 @@
import { service } from "@ember/service";
import { ajax } from "discourse/lib/ajax";
import DiscourseRoute from "discourse/routes/discourse";
+import { findQueries } from "discourse/plugins/discourse-data-explorer/discourse/data/builders/queries";
export default class AdminPluginsExplorerIndex extends DiscourseRoute {
@service router;
+ @service warpStore;
beforeModel(transition) {
// Redirect old `?id=123` URLs to query details.
@@ -16,34 +18,21 @@ export default class AdminPluginsExplorerIndex extends DiscourseRoute {
}
async model(_params, transition) {
- const filterParams = this.controllerFor(
- "adminPlugins.show.explorer.index"
- ).fetchParams;
- const tags = transition.to.queryParams.tags;
- if (tags) {
- filterParams.tags = tags;
- } else {
- delete filterParams.tags;
- }
- const [groups, model] = await Promise.all([
- ajax("/admin/plugins/discourse-data-explorer/groups.json"),
- this.store.findAll("query", filterParams),
+ const controller = this.controllerFor("adminPlugins.show.explorer.index");
+ const [{ content }, queryTags] = await Promise.all([
+ this.warpStore.request(
+ findQueries({
+ ...controller.fetchParams,
+ tags: transition.to.queryParams.tags?.split(","),
+ })
+ ),
+ ajax("/admin/plugins/discourse-data-explorer/queries/tags.json"),
]);
- const groupNames = {};
- groups.forEach((g) => {
- groupNames[g.id] = g.name;
- });
- model.content.forEach((query) => {
- query.set(
- "group_names",
- (query.group_ids || []).map((id) => groupNames[id])
- );
- });
- return { model, groups, queryTags: model.extras?.tags ?? [] };
+ return { document: content, queryTags };
}
- setupController(controller, model) {
- controller.setProperties(model);
+ setupController(controller, { document, queryTags }) {
+ controller.reset(document, queryTags);
}
}
diff --git a/plugins/discourse-data-explorer/spec/system/browse_queries_spec.rb b/plugins/discourse-data-explorer/spec/system/browse_queries_spec.rb
new file mode 100644
index 00000000000..5281a818c9c
--- /dev/null
+++ b/plugins/discourse-data-explorer/spec/system/browse_queries_spec.rb
@@ -0,0 +1,60 @@
+# frozen_string_literal: true
+
+RSpec.describe "Browse queries" do
+ fab!(:admin)
+ fab!(:alice) { Fabricate(:user, username: "alice") }
+
+ let(:queries_page) { PageObjects::Pages::DataExplorerQueries.new }
+
+ before do
+ SiteSetting.data_explorer_enabled = true
+ sign_in(admin)
+ end
+
+ it "lets the admin browse every query, its author, groups and last run" do
+ DiscourseDataExplorer::DefaultQuerySync.execute
+ recent = Fabricate(:query, user: alice, last_run_at: 1.hour.ago)
+ widely_shared = Fabricate(:query, user: alice, last_run_at: 2.hours.ago)
+ shared_groups = Fabricate.times(26, :group)
+ shared_groups.each { |group| Fabricate(:query_group, query: widely_shared, group:) }
+ never_run = Fabricate(:query, user: alice, last_run_at: nil)
+ default_query = DiscourseDataExplorer::Query.where("id < 0").first
+
+ queries_page.visit
+
+ expect(queries_page).to have_author(recent, alice)
+ expect(queries_page).to have_last_run(recent)
+ expect(queries_page).to have_editable(recent)
+ expect(queries_page).to have_groups(widely_shared, shared_groups)
+ expect(queries_page).to have_query_count(50)
+
+ queries_page.scroll_to_end
+
+ expect(queries_page).to have_query_count(DiscourseDataExplorer::Query.count)
+ expect(queries_page).to have_no_last_run(never_run)
+ expect(queries_page).to have_view_only(default_query)
+ end
+
+ it "lets the admin narrow queries by tags and search, and keeps that when they come back" do
+ monthly_revenue = Fabricate(:query, name: "Monthly revenue")
+ refunds = Fabricate(:query, name: "Refunds")
+ monthly_signups = Fabricate(:query, name: "Monthly signups")
+ DiscourseDataExplorer::QueryTag.sync!(query: monthly_revenue, names: %w[finance monthly])
+ DiscourseDataExplorer::QueryTag.sync!(query: refunds, names: %w[finance])
+ DiscourseDataExplorer::QueryTag.sync!(query: monthly_signups, names: %w[monthly])
+
+ queries_page.visit.filter_by_tag(monthly_revenue, "finance")
+
+ expect(queries_page).to have_queries([monthly_revenue, refunds])
+
+ queries_page.filter_by_tag(monthly_revenue, "monthly")
+
+ expect(queries_page).to have_queries([monthly_revenue])
+
+ queries_page.search("revenue").open(monthly_revenue).back_to_list
+
+ expect(queries_page).to have_tag_filters(%w[finance monthly])
+ expect(queries_page).to have_search("revenue")
+ expect(queries_page).to have_queries([monthly_revenue])
+ end
+end
diff --git a/plugins/discourse-data-explorer/spec/system/page_objects/pages/data_explorer_queries.rb b/plugins/discourse-data-explorer/spec/system/page_objects/pages/data_explorer_queries.rb
new file mode 100644
index 00000000000..edd8aad740b
--- /dev/null
+++ b/plugins/discourse-data-explorer/spec/system/page_objects/pages/data_explorer_queries.rb
@@ -0,0 +1,93 @@
+# frozen_string_literal: true
+
+module PageObjects
+ module Pages
+ class DataExplorerQueries < PageObjects::Pages::Base
+ ROW = ".query-row"
+ SEARCH_INPUT = ".d-filter-controls__input"
+ TAG_FILTER = ".query-tag-filter .d-multi-select-trigger__selected-item"
+
+ def visit
+ page.visit("/admin/plugins/discourse-data-explorer/queries")
+ self
+ end
+
+ def has_query_count?(count)
+ page.has_css?(ROW, count:)
+ end
+
+ def has_queries?(queries)
+ has_query_count?(queries.size) && queries.all? { page.has_css?(row(it)) }
+ end
+
+ def has_author?(query, user)
+ page.has_css?("#{row(query)} .query-created-by", text: user.username)
+ end
+
+ def has_groups?(query, groups)
+ groups.all? { page.has_css?("#{row(query)} .query-group-names a", exact_text: it.name) }
+ end
+
+ def has_last_run?(query)
+ page.has_css?("#{row(query)} .query-created-at .relative-date")
+ end
+
+ def has_no_last_run?(query)
+ page.has_css?(row(query)) &&
+ page.has_no_css?("#{row(query)} .query-created-at .relative-date")
+ end
+
+ def has_view_only?(query)
+ has_action?(query, I18n.t("js.explorer.view_query"))
+ end
+
+ def has_editable?(query)
+ has_action?(query, I18n.t("js.edit"))
+ end
+
+ def has_tag_filters?(tag_names)
+ page.has_css?(TAG_FILTER, count: tag_names.size) &&
+ tag_names.all? { page.has_css?(TAG_FILTER, exact_text: it) }
+ end
+
+ def has_search?(text)
+ page.has_css?(SEARCH_INPUT) { it.value == text }
+ end
+
+ def filter_by_tag(query, tag_name)
+ page.find("#{row(query)} .query-tags .d-table-badge", exact_text: tag_name).click
+ self
+ end
+
+ def search(text)
+ page.find(SEARCH_INPUT).fill_in(with: text)
+ self
+ end
+
+ def scroll_to_end
+ page.execute_script("window.scrollTo(0, document.body.scrollHeight)")
+ self
+ end
+
+ def open(query)
+ page.find("#{row(query)} .d-table__overview-link").click
+ self
+ end
+
+ def back_to_list
+ page.find(".back-button").click
+ self
+ end
+
+ private
+
+ def row(query)
+ "#{ROW}:has(a[href$='/queries/#{query.id}'])"
+ end
+
+ def has_action?(query, label)
+ page.has_css?("#{row(query)} .d-table__cell-actions a", exact_text: label)
+ end
+ end
+ end
+end
diff --git a/plugins/discourse-data-explorer/test/javascripts/acceptance/list-queries-test.js b/plugins/discourse-data-explorer/test/javascripts/acceptance/list-queries-test.js
index a275b8a904e..becbdc87170 100644
--- a/plugins/discourse-data-explorer/test/javascripts/acceptance/list-queries-test.js
+++ b/plugins/discourse-data-explorer/test/javascripts/acceptance/list-queries-test.js
@@ -1,6 +1,5 @@
import {
click,
- currentURL,
fillIn,
find,
settled,
@@ -8,24 +7,36 @@ import {
waitUntil,
} from "@ember/test-helpers";
import { test } from "qunit";
-import pretender from "discourse/tests/helpers/create-pretender";
+import { JSON_API_VERSION } from "discourse/data/handlers/json-api";
+import pretender, { response } from "discourse/tests/helpers/create-pretender";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
-import { i18n } from "discourse-i18n";
+
+function listDocument(id, name) {
+ return {
+ data: [
+ {
+ type: "queries",
+ id,
+ attributes: { name, description: "", tags: [] },
+ relationships: { user: { data: null }, groups: { data: [] } },
+ },
+ ],
+ };
+}
acceptance("List Queries", function (needs) {
needs.user();
needs.settings({ data_explorer_enabled: true });
- let lastQueryParams;
- let handleQueries;
+ let lastRequest;
needs.hooks.beforeEach(() => {
- lastQueryParams = null;
+ lastRequest = null;
});
needs.pretender((server, helper) => {
- server.get("/admin/plugins/discourse-data-explorer.json", () => {
- return helper.response({
+ server.get("/admin/plugins/discourse-data-explorer.json", () =>
+ helper.response({
id: "discourse-data-explorer",
name: "discourse-data-explorer",
enabled: true,
@@ -37,241 +48,51 @@ acceptance("List Queries", function (needs) {
location: "discourse-data-explorer",
use_new_show_route: true,
},
- });
- });
-
- server.get("/admin/plugins/discourse-data-explorer/groups.json", () => {
- return helper.response([]);
- });
-
- server.get("/admin/plugins/discourse-data-explorer/schema.json", () => {
- return helper.response({});
- });
-
- server.get(
- "/admin/plugins/discourse-data-explorer/queries/tags.json",
- () => {
- return helper.response(["default", "staff"]);
- }
+ })
);
-
- server.get("/admin/plugins/discourse-data-explorer/queries/1", () => {
- return helper.response({
- query: {
- id: 1,
- name: "Staff activity",
- description: "Shows staff activity.",
- sql: "SELECT 1",
- param_info: [],
- group_ids: [],
- tags: ["staff"],
- user_id: 1,
- is_default: false,
- },
- });
- });
-
- handleQueries = (request) => {
- lastQueryParams = request.queryParams;
- const queries = [
- {
- id: -6,
- name: "Top 100 Likers",
- description:
- "returns the top 100 likers for a given monthly period ordered by like_count. It accepts a ‘months_ago’ parameter, defaults to 1 to give results for the last calendar month.",
- username: "system",
- group_ids: [],
- last_run_at: "2021-02-11T08:29:59.337Z",
- user_id: -1,
- tags: ["default", "staff"],
- },
- {
- id: -5,
- name: "Top 100 Active Topics",
- description:
- "based on the number of replies, it accepts a ‘months_ago’ parameter, defaults to 1 to give results for the last calendar month.",
- username: "system",
- group_ids: [],
- last_run_at: "2021-02-08T15:37:49.188Z",
- user_id: -1,
- tags: ["default"],
- },
- {
- id: 1,
- name: "Staff activity",
- description: "Shows staff activity.",
- username: "admin",
- group_ids: [],
- last_run_at: "2021-02-07T15:37:49.188Z",
- user_id: 1,
- tags: ["staff"],
- },
- ];
- const tags = request.queryParams.tags?.split(",") ?? [];
- const filter = request.queryParams.filter?.toLowerCase();
- const filteredQueries = queries.filter((query) => {
- return (
- tags.every((tag) => query.tags.includes(tag)) &&
- (!filter || query.name.toLowerCase().includes(filter))
- );
- });
-
- return helper.response({
- queries: filteredQueries,
- total_rows_queries: filteredQueries.length,
- extras: { tags: ["default", "staff"] },
- });
- };
-
- server.get("/admin/plugins/discourse-data-explorer/queries", handleQueries);
- server.get(
- "/admin/plugins/discourse-data-explorer/queries.json",
- handleQueries
+ server.get("/admin/plugins/discourse-data-explorer/queries/tags.json", () =>
+ helper.response(["default", "staff"])
);
+ server.get("/api/data-explorer/queries", (request) => {
+ lastRequest = request;
+ return helper.response(listDocument("1", "Initial query"));
+ });
});
- test("renders the page with the list of queries", async function (assert) {
- await visit("/admin/plugins/discourse-data-explorer/queries");
-
- assert
- .dom(".d-filter-controls__input")
- .hasAttribute(
- "placeholder",
- i18n("explorer.search_placeholder"),
- "the search box was rendered"
- );
-
- assert
- .dom(".d-page-subheader .btn-primary")
- .exists("the add query button was rendered");
-
- assert
- .dom(".d-page-subheader .d-page-action-wrapped-button")
- .hasText(i18n("explorer.import.label"), "the import button was rendered");
-
- assert
- .dom("div.container table.recent-queries tbody tr")
- .exists({ count: 3 }, "the list of queries was rendered");
-
- assert
- .dom("div.container table.recent-queries tbody tr:nth-child(1) td")
- .hasText(/^\s*Top 100 Likers/, "The first query was rendered");
-
- assert
- .dom("div.container table.recent-queries tbody tr:nth-child(2) td")
- .hasText(/^\s*Top 100 Active Topics/, "The second query was rendered");
-
- assert
- .dom(".query-badge")
- .doesNotExist("default queries do not render a separate badge");
-
- assert
- .dom(".query-row:first-child .query-tags .d-table-badge")
- .exists({ count: 2 }, "the query tags appear below its description");
-
- assert
- .dom(".query-tag-filter .d-multi-select-trigger__label")
- .hasText(
- i18n("explorer.filter_by_tag"),
- "the tag filter shows its placeholder initially"
- );
- });
-
- test("filters by multiple tags", async function (assert) {
+ test("requests the JSON:API endpoint with its version and sort", async function (assert) {
await visit("/admin/plugins/discourse-data-explorer/queries");
- await click(".query-tag-filter.d-multi-select-trigger");
- await click(".d-multi-select__result:first-child");
-
- assert
- .dom(".query-tag-filter .d-multi-select-trigger__selection-label")
- .hasText("default", "the selected default tag is displayed in lowercase");
-
- assert
- .dom("div.container table.recent-queries tbody tr")
- .exists({ count: 2 }, "only default queries are shown");
-
- await click(".d-multi-select__result:first-child");
-
- assert
- .dom(".query-tag-filter .d-multi-select-trigger__selected-item")
- .exists({ count: 2 }, "both selected tags remain visible");
- assert.strictEqual(lastQueryParams.tags, "default,staff");
assert.strictEqual(
- new URLSearchParams(currentURL().split("?")[1]).get("tags"),
- "default,staff",
- "the selected tags are reflected in the URL"
+ lastRequest.requestHeaders["Api-Version"],
+ JSON_API_VERSION
);
- assert
- .dom("div.container table.recent-queries tbody tr td")
- .hasText(/^\s*Top 100 Likers/, "only queries with both tags are shown");
+ assert.deepEqual(lastRequest.queryParams.include, ["groups", "user"]);
+ assert.strictEqual(lastRequest.queryParams.sort, "-lastRunAt");
+
+ await click("#table-header-toggle-username");
+ assert.strictEqual(lastRequest.queryParams.sort, "-user.username");
+
+ await click("#table-header-toggle-username");
+ assert.strictEqual(lastRequest.queryParams.sort, "user.username");
});
- test("filters by tags from the URL", async function (assert) {
+ test("sends the tag filter and search as JSON:API filters", async function (assert) {
await visit(
"/admin/plugins/discourse-data-explorer/queries?tags=default,staff"
);
- assert.strictEqual(lastQueryParams.tags, "default,staff");
- assert
- .dom(".query-tag-filter .d-multi-select-trigger__selected-item")
- .exists({ count: 2 }, "both URL tags are selected");
- assert
- .dom(".recent-queries tbody tr")
- .exists({ count: 1 }, "only the query with both tags is shown");
+ assert.deepEqual(lastRequest.queryParams["filter[tag]"], [
+ "default",
+ "staff",
+ ]);
await fillIn(".d-filter-controls__input", "likers");
- assert.strictEqual(lastQueryParams.tags, "default,staff");
- assert.strictEqual(lastQueryParams.filter, "likers");
- });
-
- test("filters by clicking a query tag", async function (assert) {
- await visit("/admin/plugins/discourse-data-explorer/queries");
- await click(".query-row:first-child .query-tags .d-table-badge:last-child");
-
- assert.strictEqual(lastQueryParams.tags, "staff");
- assert
- .dom(".recent-queries tbody tr")
- .exists({ count: 2 }, "only queries with the clicked tag are shown");
- });
-
- test("keeps tag and text filters when returning from a query", async function (assert) {
- await visit("/admin/plugins/discourse-data-explorer/queries");
-
- await click(".query-tag-filter.d-multi-select-trigger");
- await click(".d-multi-select__result:nth-child(2)");
- await fillIn(".d-filter-controls__input", "activity");
-
- await click(".d-table__overview-link");
- await click(".back-button");
- assert.strictEqual(
- lastQueryParams.tags,
+ assert.deepEqual(lastRequest.queryParams["filter[tag]"], [
+ "default",
"staff",
- "the tag is sent on return"
- );
- assert.strictEqual(
- lastQueryParams.filter,
- "activity",
- "the text search is sent on return"
- );
- assert.strictEqual(
- new URLSearchParams(currentURL().split("?")[1]).get("tags"),
- "staff",
- "the tag remains in the URL on return"
- );
- assert
- .dom(".query-tag-filter .d-multi-select-trigger__selection-label")
- .hasText("staff", "the selected tag remains visible");
- assert
- .dom(".d-filter-controls__input")
- .hasValue("activity", "the text search remains visible");
- assert
- .dom("div.container table.recent-queries tbody tr")
- .exists({ count: 1 }, "the returned list still applies both filters");
- assert
- .dom("div.container table.recent-queries tbody tr td")
- .hasText(/^\s*Staff activity/, "the matching query remains visible");
+ ]);
+ assert.strictEqual(lastRequest.queryParams["filter[search]"], "likers");
});
test("ignores an older tag-filter response that finishes last", async function (assert) {
@@ -279,10 +100,13 @@ acceptance("List Queries", function (needs) {
const requests = [];
pretender.get(
- "/admin/plugins/discourse-data-explorer/queries.json",
+ "/api/data-explorer/queries",
(request) => {
requests.push(request);
- return handleQueries(request);
+ if (request.queryParams["filter[tag]"]?.includes("default")) {
+ return response(listDocument("2", "Top 100 Likers"));
+ }
+ return response(listDocument("3", "Staff activity"));
},
true
);
@@ -296,7 +120,7 @@ acceptance("List Queries", function (needs) {
await waitUntil(() => requests.length === 2);
pretender.resolve(requests[1]);
await waitUntil(() =>
- find(".recent-queries tbody tr:last-child td")?.textContent.includes(
+ find(".recent-queries tbody tr td")?.textContent.includes(
"Staff activity"
)
);
@@ -304,7 +128,7 @@ acceptance("List Queries", function (needs) {
await settled();
assert
- .dom(".recent-queries tbody tr:last-child td")
+ .dom(".recent-queries tbody tr td")
.hasText(
/^\s*Staff activity/,
"the latest filter results remain visible"
diff --git a/plugins/discourse-data-explorer/test/javascripts/acceptance/new-query-test.js b/plugins/discourse-data-explorer/test/javascripts/acceptance/new-query-test.js
index c8c54725df3..2eae2718f68 100644
--- a/plugins/discourse-data-explorer/test/javascripts/acceptance/new-query-test.js
+++ b/plugins/discourse-data-explorer/test/javascripts/acceptance/new-query-test.js
@@ -67,10 +67,8 @@ acceptance("New Query", function (needs) {
helper.response(["default", "staff"])
);
- server.get("/admin/plugins/discourse-data-explorer/queries", () => {
- return helper.response({
- queries: [],
- });
+ server.get("/api/data-explorer/queries", () => {
+ return helper.response({ data: [] });
});
server.post("/admin/plugins/discourse-data-explorer/queries", (request) => {
@@ -288,9 +286,6 @@ acceptance("New Query - AI", function (needs) {
server.get("/admin/plugins/discourse-data-explorer/queries/tags.json", () =>
helper.response(["default", "staff"])
);
- server.get("/admin/plugins/discourse-data-explorer/queries", () =>
- helper.response({ queries: [] })
- );
server.post(
"/admin/plugins/discourse-data-explorer/queries/generate.json",
diff --git a/plugins/discourse-data-explorer/test/javascripts/acceptance/param-input-test.js b/plugins/discourse-data-explorer/test/javascripts/acceptance/param-input-test.js
index 57ed4f08098..9bb51662293 100644
--- a/plugins/discourse-data-explorer/test/javascripts/acceptance/param-input-test.js
+++ b/plugins/discourse-data-explorer/test/javascripts/acceptance/param-input-test.js
@@ -41,41 +41,6 @@ acceptance("Param Input", function (needs) {
helper.response(["default"])
);
- server.get("/admin/plugins/discourse-data-explorer/queries", () => {
- return helper.response({
- queries: [
- {
- id: -6,
- name: "Top 100 Likers",
- description:
- "returns the top 100 likers for a given monthly period ordered by like_count. It accepts a ‘months_ago’ parameter, defaults to 1 to give results for the last calendar month.",
- username: "system",
- group_ids: [],
- last_run_at: "2021-02-11T08:29:59.337Z",
- user_id: -1,
- },
- {
- id: -7,
- name: "Invalid Query",
- description: "",
- username: "bianca",
- group_ids: [],
- last_run_at: "2022-01-14T16:47:34.244Z",
- user_id: 1,
- },
- {
- id: 3,
- name: "Params test",
- description: "test for params.",
- username: "system",
- group_ids: [41],
- last_run_at: "2021-02-11T08:29:59.337Z",
- user_id: -1,
- },
- ],
- });
- });
-
server.get("/admin/plugins/discourse-data-explorer/queries/-6", () => {
return helper.response({
query: {
diff --git a/plugins/discourse-data-explorer/test/javascripts/acceptance/run-query-test.js b/plugins/discourse-data-explorer/test/javascripts/acceptance/run-query-test.js
index fe95004c473..4ff39574bd3 100644
--- a/plugins/discourse-data-explorer/test/javascripts/acceptance/run-query-test.js
+++ b/plugins/discourse-data-explorer/test/javascripts/acceptance/run-query-test.js
@@ -135,34 +135,8 @@ acceptance("Run Query", function (needs) {
helper.response(["default", "existing"])
);
- server.get("/admin/plugins/discourse-data-explorer/queries", () => {
- return helper.response({
- queries: [
- {
- id: -6,
- name: "Top 100 Likers",
- description:
- "returns the top 100 likers for a given monthly period ordered by like_count. It accepts a ‘months_ago’ parameter, defaults to 1 to give results for the last calendar month.",
- username: "system",
- group_ids: [],
- tags: ["default"],
- last_run_at: "2021-02-11T08:29:59.337Z",
- user_id: -1,
- is_default: true,
- },
- {
- id: 2,
- name: "What about 0?",
- description: "",
- username: "system",
- group_ids: [],
- tags: ["custom", "existing"],
- last_run_at: "2023-05-04T22:16:23.858Z",
- user_id: 1,
- is_default: false,
- },
- ],
- });
+ server.get("/api/data-explorer/queries", () => {
+ return helper.response({ data: [] });
});
server.get("/admin/plugins/discourse-data-explorer/queries/-6", () => {