Skip to content

Commit

Permalink
chore: better filtering of test search queries for more accurate data (
Browse files Browse the repository at this point in the history
…#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
  • Loading branch information
SiTaggart authored Feb 2, 2024
1 parent e087bfa commit 820074b
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 157 deletions.
2 changes: 1 addition & 1 deletion apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"generate:db-types": "yarn supabase gen types typescript --local > supabase/schema.gen.ts"
},
"devDependencies": {
"supabase": "^1.99.5"
"supabase": "^1.136.3"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
set check_function_bodies = off;

CREATE OR REPLACE FUNCTION public.match_weekly_search_usage()
RETURNS TABLE(query_string character varying, count bigint)
LANGUAGE plpgsql
AS $function$
begin
return query
SELECT
queries.query_string,
count(*) as count
FROM
queries
WHERE
type = 'docs-search'
AND queries.query_string != 'dsys'
AND queries.query_string != 'this is a search test'
AND queries.created_at >= now() - interval '1 week'
GROUP BY
queries.query_string
ORDER BY
count DESC
LIMIT 20;
end;
$function$
;


99 changes: 91 additions & 8 deletions apps/backend/supabase/schema.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export interface Database {
{
foreignKeyName: "page_parent_page_id_fkey"
columns: ["parent_page_id"]
isOneToOne: false
referencedRelation: "page"
referencedColumns: ["id"]
}
Expand Down Expand Up @@ -109,6 +110,7 @@ export interface Database {
{
foreignKeyName: "page_section_page_id_fkey"
columns: ["page_id"]
isOneToOne: false
referencedRelation: "page"
referencedColumns: ["id"]
}
Expand Down Expand Up @@ -191,6 +193,7 @@ export interface Database {
{
foreignKeyName: "story_render_story_id_fkey"
columns: ["story_id"]
isOneToOne: false
referencedRelation: "story"
referencedColumns: ["id"]
}
Expand Down Expand Up @@ -363,6 +366,7 @@ export interface Database {
id: string
name: string
owner: string | null
owner_id: string | null
public: boolean | null
updated_at: string | null
}
Expand All @@ -374,6 +378,7 @@ export interface Database {
id: string
name: string
owner?: string | null
owner_id?: string | null
public?: boolean | null
updated_at?: string | null
}
Expand All @@ -385,17 +390,11 @@ export interface Database {
id?: string
name?: string
owner?: string | null
owner_id?: string | null
public?: boolean | null
updated_at?: string | null
}
Relationships: [
{
foreignKeyName: "buckets_owner_fkey"
columns: ["owner"]
referencedRelation: "users"
referencedColumns: ["id"]
}
]
Relationships: []
}
migrations: {
Row: {
Expand Down Expand Up @@ -427,6 +426,7 @@ export interface Database {
metadata: Json | null
name: string | null
owner: string | null
owner_id: string | null
path_tokens: string[] | null
updated_at: string | null
version: string | null
Expand All @@ -439,6 +439,7 @@ export interface Database {
metadata?: Json | null
name?: string | null
owner?: string | null
owner_id?: string | null
path_tokens?: string[] | null
updated_at?: string | null
version?: string | null
Expand All @@ -451,6 +452,7 @@ export interface Database {
metadata?: Json | null
name?: string | null
owner?: string | null
owner_id?: string | null
path_tokens?: string[] | null
updated_at?: string | null
version?: string | null
Expand All @@ -459,6 +461,7 @@ export interface Database {
{
foreignKeyName: "objects_bucketId_fkey"
columns: ["bucket_id"]
isOneToOne: false
referencedRelation: "buckets"
referencedColumns: ["id"]
}
Expand Down Expand Up @@ -533,3 +536,83 @@ export interface Database {
}
}

export type Tables<
PublicTableNameOrOptions extends
| keyof (Database["public"]["Tables"] & Database["public"]["Views"])
| { schema: keyof Database },
TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
? keyof (Database[PublicTableNameOrOptions["schema"]]["Tables"] &
Database[PublicTableNameOrOptions["schema"]]["Views"])
: never = never
> = PublicTableNameOrOptions extends { schema: keyof Database }
? (Database[PublicTableNameOrOptions["schema"]]["Tables"] &
Database[PublicTableNameOrOptions["schema"]]["Views"])[TableName] extends {
Row: infer R
}
? R
: never
: PublicTableNameOrOptions extends keyof (Database["public"]["Tables"] &
Database["public"]["Views"])
? (Database["public"]["Tables"] &
Database["public"]["Views"])[PublicTableNameOrOptions] extends {
Row: infer R
}
? R
: never
: never

export type TablesInsert<
PublicTableNameOrOptions extends
| keyof Database["public"]["Tables"]
| { schema: keyof Database },
TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"]
: never = never
> = PublicTableNameOrOptions extends { schema: keyof Database }
? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends {
Insert: infer I
}
? I
: never
: PublicTableNameOrOptions extends keyof Database["public"]["Tables"]
? Database["public"]["Tables"][PublicTableNameOrOptions] extends {
Insert: infer I
}
? I
: never
: never

export type TablesUpdate<
PublicTableNameOrOptions extends
| keyof Database["public"]["Tables"]
| { schema: keyof Database },
TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"]
: never = never
> = PublicTableNameOrOptions extends { schema: keyof Database }
? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends {
Update: infer U
}
? U
: never
: PublicTableNameOrOptions extends keyof Database["public"]["Tables"]
? Database["public"]["Tables"][PublicTableNameOrOptions] extends {
Update: infer U
}
? U
: never
: never

export type Enums<
PublicEnumNameOrOptions extends
| keyof Database["public"]["Enums"]
| { schema: keyof Database },
EnumName extends PublicEnumNameOrOptions extends { schema: keyof Database }
? keyof Database[PublicEnumNameOrOptions["schema"]]["Enums"]
: never = never
> = PublicEnumNameOrOptions extends { schema: keyof Database }
? Database[PublicEnumNameOrOptions["schema"]]["Enums"][EnumName]
: PublicEnumNameOrOptions extends keyof Database["public"]["Enums"]
? Database["public"]["Enums"][PublicEnumNameOrOptions]
: never

2 changes: 1 addition & 1 deletion cypress/integration/api/discussions-search.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
context("GET /api/discussions-search", () => {
it("gets a list of discussions", () => {
cy.request("POST", "/api/discussions-search", { prompt: "creating a button" }).then((response) => {
cy.request("POST", "/api/discussions-search", { prompt: "this is a search test" }).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.data).length.to.be.greaterThan(1);
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/api/docs-search.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
context("GET /api/docs-search", () => {
it("gets a list of docs", () => {
cy.request("POST", "/api/docs-search", { prompt: "creating a button" }).then((response) => {
cy.request("POST", "/api/docs-search", { prompt: "this is a search test" }).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.data).length.to.be.greaterThan(1);
});
Expand Down
10 changes: 6 additions & 4 deletions cypress/integration/api/paste-assistant-message.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ context("POST /api/paste-assistant-message", () => {

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

it("gets messages on an ai thread", () => {
// get messages on the thread
cy.request("GET", `/api/paste-assistant-messages/${threadId}`).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.data).length.to.be.greaterThan(0);
expect(response.body.data[0].content[0].text.value).to.eq("create a button");
expect(response.body.data[0].content[0].text.value).to.eq("this is a search test");
});
});
});
2 changes: 1 addition & 1 deletion cypress/integration/site-search/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe("Docs website search", () => {
cy.get('[data-cy="paste-docsearch-input"]')
.should("be.visible")
.should("be.focused")
.type("checkbox")
.type("this is a search test")
.type("{enter}");
cy.wait("@searchRequest");
cy.get('[data-cy="paste-docsearch-hits"] h2').should("have.length.above", 0);
Expand Down
Loading

0 comments on commit 820074b

Please sign in to comment.