Skip to content

Commit

Permalink
feat: allow searching space by domain (#928)
Browse files Browse the repository at this point in the history
* feat: allow searching space by domain

* fix: use column for faster query
  • Loading branch information
wa0x6e authored Sep 24, 2024
1 parent 36e63fd commit ae99cfa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/graphql/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,11 @@ export async function fetchSpaces(args) {
params.push(where.plugin);
}

if (where.domain) {
queryStr += ` AND domain = ?`;
params.push(where.domain);
}

const query = `
SELECT s.* FROM spaces s
WHERE s.deleted = 0 ${queryStr}
Expand Down
1 change: 1 addition & 0 deletions src/graphql/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ input SpaceWhere {
plugin: String
controller: String
verified: Boolean
domain: String
}

input RankingWhere {
Expand Down
2 changes: 2 additions & 0 deletions src/helpers/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ CREATE TABLE spaces (
proposal_count INT NOT NULL DEFAULT '0',
vote_count INT NOT NULL DEFAULT '0',
follower_count INT NOT NULL DEFAULT '0',
domain VARCHAR(64) DEFAULT NULL,
created BIGINT NOT NULL,
updated BIGINT NOT NULL,
PRIMARY KEY (id),
INDEX name (name),
UNIQUE KEY domain (domain),
INDEX verified (verified),
INDEX flagged (flagged),
INDEX hibernated (hibernated),
Expand Down

0 comments on commit ae99cfa

Please sign in to comment.