Skip to content

Commit 820074b

Browse files
authored
chore: better filtering of test search queries for more accurate data (#3752)
* chore: better filtering of test search queries for more accurate data * chore: upgrade supabase cli client * chore: db types * chore: db types with updated supabase
1 parent e087bfa commit 820074b

File tree

8 files changed

+146
-157
lines changed

8 files changed

+146
-157
lines changed

apps/backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
"generate:db-types": "yarn supabase gen types typescript --local > supabase/schema.gen.ts"
99
},
1010
"devDependencies": {
11-
"supabase": "^1.99.5"
11+
"supabase": "^1.136.3"
1212
}
1313
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
set check_function_bodies = off;
2+
3+
CREATE OR REPLACE FUNCTION public.match_weekly_search_usage()
4+
RETURNS TABLE(query_string character varying, count bigint)
5+
LANGUAGE plpgsql
6+
AS $function$
7+
begin
8+
return query
9+
SELECT
10+
queries.query_string,
11+
count(*) as count
12+
FROM
13+
queries
14+
WHERE
15+
type = 'docs-search'
16+
AND queries.query_string != 'dsys'
17+
AND queries.query_string != 'this is a search test'
18+
AND queries.created_at >= now() - interval '1 week'
19+
GROUP BY
20+
queries.query_string
21+
ORDER BY
22+
count DESC
23+
LIMIT 20;
24+
end;
25+
$function$
26+
;
27+
28+

apps/backend/supabase/schema.gen.ts

Lines changed: 91 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export interface Database {
7272
{
7373
foreignKeyName: "page_parent_page_id_fkey"
7474
columns: ["parent_page_id"]
75+
isOneToOne: false
7576
referencedRelation: "page"
7677
referencedColumns: ["id"]
7778
}
@@ -109,6 +110,7 @@ export interface Database {
109110
{
110111
foreignKeyName: "page_section_page_id_fkey"
111112
columns: ["page_id"]
113+
isOneToOne: false
112114
referencedRelation: "page"
113115
referencedColumns: ["id"]
114116
}
@@ -191,6 +193,7 @@ export interface Database {
191193
{
192194
foreignKeyName: "story_render_story_id_fkey"
193195
columns: ["story_id"]
196+
isOneToOne: false
194197
referencedRelation: "story"
195198
referencedColumns: ["id"]
196199
}
@@ -363,6 +366,7 @@ export interface Database {
363366
id: string
364367
name: string
365368
owner: string | null
369+
owner_id: string | null
366370
public: boolean | null
367371
updated_at: string | null
368372
}
@@ -374,6 +378,7 @@ export interface Database {
374378
id: string
375379
name: string
376380
owner?: string | null
381+
owner_id?: string | null
377382
public?: boolean | null
378383
updated_at?: string | null
379384
}
@@ -385,17 +390,11 @@ export interface Database {
385390
id?: string
386391
name?: string
387392
owner?: string | null
393+
owner_id?: string | null
388394
public?: boolean | null
389395
updated_at?: string | null
390396
}
391-
Relationships: [
392-
{
393-
foreignKeyName: "buckets_owner_fkey"
394-
columns: ["owner"]
395-
referencedRelation: "users"
396-
referencedColumns: ["id"]
397-
}
398-
]
397+
Relationships: []
399398
}
400399
migrations: {
401400
Row: {
@@ -427,6 +426,7 @@ export interface Database {
427426
metadata: Json | null
428427
name: string | null
429428
owner: string | null
429+
owner_id: string | null
430430
path_tokens: string[] | null
431431
updated_at: string | null
432432
version: string | null
@@ -439,6 +439,7 @@ export interface Database {
439439
metadata?: Json | null
440440
name?: string | null
441441
owner?: string | null
442+
owner_id?: string | null
442443
path_tokens?: string[] | null
443444
updated_at?: string | null
444445
version?: string | null
@@ -451,6 +452,7 @@ export interface Database {
451452
metadata?: Json | null
452453
name?: string | null
453454
owner?: string | null
455+
owner_id?: string | null
454456
path_tokens?: string[] | null
455457
updated_at?: string | null
456458
version?: string | null
@@ -459,6 +461,7 @@ export interface Database {
459461
{
460462
foreignKeyName: "objects_bucketId_fkey"
461463
columns: ["bucket_id"]
464+
isOneToOne: false
462465
referencedRelation: "buckets"
463466
referencedColumns: ["id"]
464467
}
@@ -533,3 +536,83 @@ export interface Database {
533536
}
534537
}
535538

539+
export type Tables<
540+
PublicTableNameOrOptions extends
541+
| keyof (Database["public"]["Tables"] & Database["public"]["Views"])
542+
| { schema: keyof Database },
543+
TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
544+
? keyof (Database[PublicTableNameOrOptions["schema"]]["Tables"] &
545+
Database[PublicTableNameOrOptions["schema"]]["Views"])
546+
: never = never
547+
> = PublicTableNameOrOptions extends { schema: keyof Database }
548+
? (Database[PublicTableNameOrOptions["schema"]]["Tables"] &
549+
Database[PublicTableNameOrOptions["schema"]]["Views"])[TableName] extends {
550+
Row: infer R
551+
}
552+
? R
553+
: never
554+
: PublicTableNameOrOptions extends keyof (Database["public"]["Tables"] &
555+
Database["public"]["Views"])
556+
? (Database["public"]["Tables"] &
557+
Database["public"]["Views"])[PublicTableNameOrOptions] extends {
558+
Row: infer R
559+
}
560+
? R
561+
: never
562+
: never
563+
564+
export type TablesInsert<
565+
PublicTableNameOrOptions extends
566+
| keyof Database["public"]["Tables"]
567+
| { schema: keyof Database },
568+
TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
569+
? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"]
570+
: never = never
571+
> = PublicTableNameOrOptions extends { schema: keyof Database }
572+
? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends {
573+
Insert: infer I
574+
}
575+
? I
576+
: never
577+
: PublicTableNameOrOptions extends keyof Database["public"]["Tables"]
578+
? Database["public"]["Tables"][PublicTableNameOrOptions] extends {
579+
Insert: infer I
580+
}
581+
? I
582+
: never
583+
: never
584+
585+
export type TablesUpdate<
586+
PublicTableNameOrOptions extends
587+
| keyof Database["public"]["Tables"]
588+
| { schema: keyof Database },
589+
TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
590+
? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"]
591+
: never = never
592+
> = PublicTableNameOrOptions extends { schema: keyof Database }
593+
? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends {
594+
Update: infer U
595+
}
596+
? U
597+
: never
598+
: PublicTableNameOrOptions extends keyof Database["public"]["Tables"]
599+
? Database["public"]["Tables"][PublicTableNameOrOptions] extends {
600+
Update: infer U
601+
}
602+
? U
603+
: never
604+
: never
605+
606+
export type Enums<
607+
PublicEnumNameOrOptions extends
608+
| keyof Database["public"]["Enums"]
609+
| { schema: keyof Database },
610+
EnumName extends PublicEnumNameOrOptions extends { schema: keyof Database }
611+
? keyof Database[PublicEnumNameOrOptions["schema"]]["Enums"]
612+
: never = never
613+
> = PublicEnumNameOrOptions extends { schema: keyof Database }
614+
? Database[PublicEnumNameOrOptions["schema"]]["Enums"][EnumName]
615+
: PublicEnumNameOrOptions extends keyof Database["public"]["Enums"]
616+
? Database["public"]["Enums"][PublicEnumNameOrOptions]
617+
: never
618+

cypress/integration/api/discussions-search.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
context("GET /api/discussions-search", () => {
22
it("gets a list of discussions", () => {
3-
cy.request("POST", "/api/discussions-search", { prompt: "creating a button" }).then((response) => {
3+
cy.request("POST", "/api/discussions-search", { prompt: "this is a search test" }).then((response) => {
44
expect(response.status).to.eq(200);
55
expect(response.body.data).length.to.be.greaterThan(1);
66
});

cypress/integration/api/docs-search.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
context("GET /api/docs-search", () => {
22
it("gets a list of docs", () => {
3-
cy.request("POST", "/api/docs-search", { prompt: "creating a button" }).then((response) => {
3+
cy.request("POST", "/api/docs-search", { prompt: "this is a search test" }).then((response) => {
44
expect(response.status).to.eq(200);
55
expect(response.body.data).length.to.be.greaterThan(1);
66
});

cypress/integration/api/paste-assistant-message.spec.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,19 @@ context("POST /api/paste-assistant-message", () => {
1515

1616
it("creates an message on an ai thread", () => {
1717
// create a message on the thread
18-
cy.request("POST", "/api/paste-assistant-message", { threadId, message: "create a button" }).then((response) => {
19-
expect(response.status).to.eq(200);
20-
});
18+
cy.request("POST", "/api/paste-assistant-message", { threadId, message: "this is a search test" }).then(
19+
(response) => {
20+
expect(response.status).to.eq(200);
21+
},
22+
);
2123
});
2224

2325
it("gets messages on an ai thread", () => {
2426
// get messages on the thread
2527
cy.request("GET", `/api/paste-assistant-messages/${threadId}`).then((response) => {
2628
expect(response.status).to.eq(200);
2729
expect(response.body.data).length.to.be.greaterThan(0);
28-
expect(response.body.data[0].content[0].text.value).to.eq("create a button");
30+
expect(response.body.data[0].content[0].text.value).to.eq("this is a search test");
2931
});
3032
});
3133
});

cypress/integration/site-search/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe("Docs website search", () => {
1717
cy.get('[data-cy="paste-docsearch-input"]')
1818
.should("be.visible")
1919
.should("be.focused")
20-
.type("checkbox")
20+
.type("this is a search test")
2121
.type("{enter}");
2222
cy.wait("@searchRequest");
2323
cy.get('[data-cy="paste-docsearch-hits"] h2').should("have.length.above", 0);

0 commit comments

Comments
 (0)