Skip to content

Commit b5fd4a7

Browse files
committed
fix: remove trailing spaces and apply consistent formatting
1 parent efe6b3d commit b5fd4a7

File tree

4 files changed

+41
-33
lines changed

4 files changed

+41
-33
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'))

packages/api-main/tests/feed.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ describe('filter post depending on send tokens', async () => {
7474
it('filtering with large numbers (Photon filter bug fix)', async () => {
7575
// Create posts with amounts that would fail with string comparison
7676
const wallet = await createWallet();
77-
77+
7878
// Post with 500000 tokens
7979
const post500k = await post(`post`, {
8080
from: wallet.publicKey,
@@ -105,7 +105,7 @@ describe('filter post depending on send tokens', async () => {
105105
quantity: string;
106106
}[];
107107
}>(`feed?minQuantity=100000`);
108-
108+
109109
assert.isOk(filterResponse?.status === 200);
110110
const filteredMessages = filterResponse.rows.map(r => r.message);
111111
assert.include(filteredMessages, 'post with 500000 tokens', 'Should include 500k post');

packages/api-main/tests/v1.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ describe('v1', { sequential: true }, async () => {
7474

7575
it('GET - /posts with minQuantity filter (Photon bug fix)', async () => {
7676
const wallet = await createWallet();
77-
77+
7878
// Create posts with different quantities
7979
await post(`post`, {
8080
from: wallet.publicKey,
@@ -83,15 +83,15 @@ describe('v1', { sequential: true }, async () => {
8383
quantity: '100',
8484
timestamp: '2025-04-16T19:46:42Z',
8585
} as typeof Posts.PostBody.static);
86-
86+
8787
await post(`post`, {
8888
from: wallet.publicKey,
8989
hash: getRandomHash(),
9090
msg: 'high value post',
9191
quantity: '1000000',
9292
timestamp: '2025-04-16T19:46:43Z',
9393
} as typeof Posts.PostBody.static);
94-
94+
9595
// Test numeric comparison works correctly
9696
const response = await get<{ status: number; rows: { message: string; quantity: string }[] }>(
9797
`posts?address=${wallet.publicKey}&minQuantity=500000`,
@@ -103,7 +103,7 @@ describe('v1', { sequential: true }, async () => {
103103

104104
// Likes
105105
const likeablePost = await createPost('A Likeable Post');
106-
it ('should have a likeable post', () => {
106+
it('should have a likeable post', () => {
107107
assert.isOk(likeablePost);
108108
});
109109

@@ -143,7 +143,7 @@ describe('v1', { sequential: true }, async () => {
143143

144144
// Dislikes
145145
const dislikeablePost = await createPost('A Dislikeable Post');
146-
it ('should have a dislikeable post', () => {
146+
it('should have a dislikeable post', () => {
147147
assert.isOk(dislikeablePost);
148148
});
149149

@@ -183,7 +183,7 @@ describe('v1', { sequential: true }, async () => {
183183

184184
// Flags
185185
const flagPost = await createPost('A Dislikeable Post');
186-
it ('should have a dislikeable post (flag)', () => {
186+
it('should have a dislikeable post (flag)', () => {
187187
assert.isOk(flagPost);
188188
});
189189

0 commit comments

Comments
 (0)