Skip to content

Commit 48066b6

Browse files
committed
fix: apply consistent formatting to where clauses
1 parent efe6b3d commit 48066b6

File tree

2 files changed

+33
-25
lines changed

2 files changed

+33
-25
lines changed

packages/api-main/src/gets/posts.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ import { FeedTable, FollowsTable } from '../../drizzle/schema';
88
const statement = getDatabase()
99
.select()
1010
.from(FeedTable)
11-
.where(and(
12-
eq(FeedTable.author, sql.placeholder('author')),
13-
isNull(FeedTable.removed_at),
14-
isNull(FeedTable.post_hash), // Do not return replies
15-
gte(sql`CAST(${FeedTable.quantity} AS NUMERIC)`, sql`CAST(${sql.placeholder('minQuantity')} AS NUMERIC)`),
16-
))
11+
.where(
12+
and(
13+
eq(FeedTable.author, sql.placeholder('author')),
14+
isNull(FeedTable.removed_at),
15+
isNull(FeedTable.post_hash), // Do not return replies
16+
gte(sql`CAST(${FeedTable.quantity} AS NUMERIC)`, sql`CAST(${sql.placeholder('minQuantity')} AS NUMERIC)`),
17+
),
18+
)
1719
.limit(sql.placeholder('limit'))
1820
.offset(sql.placeholder('offset'))
1921
.orderBy(desc(FeedTable.timestamp))
@@ -48,15 +50,17 @@ export async function Posts(query: Gets.PostsQuery) {
4850
const followingPostsStatement = getDatabase()
4951
.select()
5052
.from(FeedTable)
51-
.where(and(
52-
inArray(FeedTable.author, getDatabase()
53-
.select({ following: FollowsTable.following })
54-
.from(FollowsTable)
55-
.where(and(eq(FollowsTable.follower, sql.placeholder('address')), isNull(FollowsTable.removed_at)))),
56-
isNull(FeedTable.post_hash),
57-
isNull(FeedTable.removed_at),
58-
gte(sql`CAST(${FeedTable.quantity} AS NUMERIC)`, sql`CAST(${sql.placeholder('minQuantity')} AS NUMERIC)`),
59-
))
53+
.where(
54+
and(
55+
inArray(FeedTable.author, getDatabase()
56+
.select({ following: FollowsTable.following })
57+
.from(FollowsTable)
58+
.where(and(eq(FollowsTable.follower, sql.placeholder('address')), isNull(FollowsTable.removed_at)))),
59+
isNull(FeedTable.post_hash),
60+
isNull(FeedTable.removed_at),
61+
gte(sql`CAST(${FeedTable.quantity} AS NUMERIC)`, sql`CAST(${sql.placeholder('minQuantity')} AS NUMERIC)`),
62+
),
63+
)
6064
.orderBy(desc(FeedTable.timestamp))
6165
.limit(sql.placeholder('limit'))
6266
.offset(sql.placeholder('offset'))

packages/api-main/src/gets/replies.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ import { FeedTable } from '../../drizzle/schema';
99
const statement = getDatabase()
1010
.select()
1111
.from(FeedTable)
12-
.where(and(
13-
eq(FeedTable.post_hash, sql.placeholder('hash')),
14-
isNull(FeedTable.removed_at),
15-
gte(sql`CAST(${FeedTable.quantity} AS NUMERIC)`, sql`CAST(${sql.placeholder('minQuantity')} AS NUMERIC)`),
16-
))
12+
.where(
13+
and(
14+
eq(FeedTable.post_hash, sql.placeholder('hash')),
15+
isNull(FeedTable.removed_at),
16+
gte(sql`CAST(${FeedTable.quantity} AS NUMERIC)`, sql`CAST(${sql.placeholder('minQuantity')} AS NUMERIC)`),
17+
),
18+
)
1719
.limit(sql.placeholder('limit'))
1820
.offset(sql.placeholder('offset'))
1921
.orderBy(desc(FeedTable.timestamp))
@@ -55,11 +57,13 @@ const getUserRepliesWithParent = getDatabase()
5557
})
5658
.from(feed)
5759
.innerJoin(parentFeed, eq(feed.post_hash, parentFeed.hash))
58-
.where(and(
59-
eq(feed.author, sql.placeholder('author')),
60-
isNotNull(feed.post_hash),
61-
gte(sql`CAST(${feed.quantity} AS NUMERIC)`, sql`CAST(${sql.placeholder('minQuantity')} AS NUMERIC)`),
62-
))
60+
.where(
61+
and(
62+
eq(feed.author, sql.placeholder('author')),
63+
isNotNull(feed.post_hash),
64+
gte(sql`CAST(${feed.quantity} AS NUMERIC)`, sql`CAST(${sql.placeholder('minQuantity')} AS NUMERIC)`),
65+
),
66+
)
6367
.orderBy(desc(feed.timestamp))
6468
.limit(sql.placeholder('limit'))
6569
.offset(sql.placeholder('offset'))

0 commit comments

Comments
 (0)