Skip to content

Commit d82ab54

Browse files
committed
refactor: replace null checks with isNotNull
1 parent 6671885 commit d82ab54

File tree

9 files changed

+285
-278
lines changed

9 files changed

+285
-278
lines changed

src/graphql/types/Comment/downVoters.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
eq,
77
exists,
88
gt,
9+
isNotNull,
910
lt,
1011
ne,
1112
or,
@@ -115,15 +116,15 @@ Comment.implement({
115116
.from(commentVotesTable)
116117
.where(
117118
and(
118-
ne(commentVotesTable.creatorId, sql`${null}`),
119+
isNotNull(commentVotesTable.creatorId),
119120
eq(commentVotesTable.createdAt, cursor.createdAt),
120121
eq(commentVotesTable.creatorId, cursor.creatorId),
121122
eq(commentVotesTable.commentId, parent.id),
122123
eq(commentVotesTable.type, "down_vote"),
123124
),
124125
),
125126
),
126-
ne(commentVotesTable.creatorId, sql`${null}`),
127+
isNotNull(commentVotesTable.creatorId),
127128
eq(commentVotesTable.commentId, parent.id),
128129
eq(commentVotesTable.type, "down_vote"),
129130
or(
@@ -136,7 +137,7 @@ Comment.implement({
136137
);
137138
} else {
138139
where = and(
139-
ne(commentVotesTable.creatorId, sql`${null}`),
140+
isNotNull(commentVotesTable.creatorId),
140141
eq(commentVotesTable.commentId, parent.id),
141142
eq(commentVotesTable.type, "down_vote"),
142143
);
@@ -150,15 +151,15 @@ Comment.implement({
150151
.from(commentVotesTable)
151152
.where(
152153
and(
153-
ne(commentVotesTable.creatorId, sql`${null}`),
154+
isNotNull(commentVotesTable.creatorId),
154155
eq(commentVotesTable.createdAt, cursor.createdAt),
155156
eq(commentVotesTable.creatorId, cursor.creatorId),
156157
eq(commentVotesTable.commentId, parent.id),
157158
eq(commentVotesTable.type, "down_vote"),
158159
),
159160
),
160161
),
161-
ne(commentVotesTable.creatorId, sql`${null}`),
162+
isNotNull(commentVotesTable.creatorId),
162163
eq(commentVotesTable.commentId, parent.id),
163164
eq(commentVotesTable.type, "down_vote"),
164165
or(
@@ -171,7 +172,7 @@ Comment.implement({
171172
);
172173
} else {
173174
where = and(
174-
ne(commentVotesTable.creatorId, sql`${null}`),
175+
isNotNull(commentVotesTable.creatorId),
175176
eq(commentVotesTable.commentId, parent.id),
176177
eq(commentVotesTable.type, "down_vote"),
177178
);

src/graphql/types/Comment/upVoters.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
eq,
77
exists,
88
gt,
9+
isNotNull,
910
lt,
1011
ne,
1112
or,
@@ -115,15 +116,15 @@ Comment.implement({
115116
.from(commentVotesTable)
116117
.where(
117118
and(
118-
ne(commentVotesTable.creatorId, sql`${null}`),
119+
isNotNull(commentVotesTable.creatorId),
119120
eq(commentVotesTable.createdAt, cursor.createdAt),
120121
eq(commentVotesTable.creatorId, cursor.creatorId),
121122
eq(commentVotesTable.commentId, parent.id),
122123
eq(commentVotesTable.type, "up_vote"),
123124
),
124125
),
125126
),
126-
ne(commentVotesTable.creatorId, sql`${null}`),
127+
isNotNull(commentVotesTable.creatorId),
127128
eq(commentVotesTable.commentId, parent.id),
128129
eq(commentVotesTable.type, "up_vote"),
129130
or(
@@ -136,7 +137,7 @@ Comment.implement({
136137
);
137138
} else {
138139
where = and(
139-
ne(commentVotesTable.creatorId, sql`${null}`),
140+
isNotNull(commentVotesTable.creatorId),
140141
eq(commentVotesTable.commentId, parent.id),
141142
eq(commentVotesTable.type, "up_vote"),
142143
);
@@ -150,15 +151,15 @@ Comment.implement({
150151
.from(commentVotesTable)
151152
.where(
152153
and(
153-
ne(commentVotesTable.creatorId, sql`${null}`),
154+
isNotNull(commentVotesTable.creatorId),
154155
eq(commentVotesTable.createdAt, cursor.createdAt),
155156
eq(commentVotesTable.creatorId, cursor.creatorId),
156157
eq(commentVotesTable.commentId, parent.id),
157158
eq(commentVotesTable.type, "up_vote"),
158159
),
159160
),
160161
),
161-
ne(commentVotesTable.creatorId, sql`${null}`),
162+
isNotNull(commentVotesTable.creatorId),
162163
eq(commentVotesTable.commentId, parent.id),
163164
eq(commentVotesTable.type, "up_vote"),
164165
or(
@@ -171,7 +172,7 @@ Comment.implement({
171172
);
172173
} else {
173174
where = and(
174-
ne(commentVotesTable.creatorId, sql`${null}`),
175+
isNotNull(commentVotesTable.creatorId),
175176
eq(commentVotesTable.commentId, parent.id),
176177
eq(commentVotesTable.type, "up_vote"),
177178
);

src/graphql/types/Event/agendaFolders.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
eq,
77
exists,
88
gt,
9+
isNotNull,
910
lt,
1011
or,
1112
sql,
@@ -103,12 +104,12 @@ Event.implement({
103104
eq(agendaFoldersTable.eventId, parent.id),
104105
eq(agendaFoldersTable.id, cursor.id),
105106
eq(agendaFoldersTable.name, cursor.name),
106-
eq(agendaFoldersTable.parentFolderId, sql`${null}`),
107+
isNotNull(agendaFoldersTable.parentFolderId),
107108
),
108109
),
109110
),
110111
eq(agendaFoldersTable.eventId, parent.id),
111-
eq(agendaFoldersTable.parentFolderId, sql`${null}`),
112+
isNotNull(agendaFoldersTable.parentFolderId),
112113
or(
113114
and(
114115
eq(agendaFoldersTable.name, cursor.name),
@@ -120,7 +121,7 @@ Event.implement({
120121
} else {
121122
where = and(
122123
eq(agendaFoldersTable.eventId, parent.id),
123-
eq(agendaFoldersTable.parentFolderId, sql`${null}`),
124+
isNotNull(agendaFoldersTable.parentFolderId),
124125
);
125126
}
126127
} else {
@@ -135,12 +136,12 @@ Event.implement({
135136
eq(agendaFoldersTable.eventId, parent.id),
136137
eq(agendaFoldersTable.id, cursor.id),
137138
eq(agendaFoldersTable.name, cursor.name),
138-
eq(agendaFoldersTable.parentFolderId, sql`${null}`),
139+
isNotNull(agendaFoldersTable.parentFolderId),
139140
),
140141
),
141142
),
142143
eq(agendaFoldersTable.eventId, parent.id),
143-
eq(agendaFoldersTable.parentFolderId, sql`${null}`),
144+
isNotNull(agendaFoldersTable.parentFolderId),
144145
or(
145146
and(
146147
eq(agendaFoldersTable.name, cursor.name),
@@ -152,7 +153,7 @@ Event.implement({
152153
} else {
153154
where = and(
154155
eq(agendaFoldersTable.eventId, parent.id),
155-
eq(agendaFoldersTable.parentFolderId, sql`${null}`),
156+
isNotNull(agendaFoldersTable.parentFolderId),
156157
);
157158
}
158159
}

src/graphql/types/Organization/pinnedPosts.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
eq,
77
exists,
88
gt,
9+
isNotNull,
910
lt,
1011
ne,
1112
or,
@@ -161,7 +162,7 @@ Organization.implement({
161162
),
162163
),
163164
),
164-
ne(postsTable.pinnedAt, sql`${null}`),
165+
isNotNull(postsTable.pinnedAt),
165166
eq(postsTable.organizationId, parent.id),
166167
or(
167168
and(
@@ -173,7 +174,7 @@ Organization.implement({
173174
);
174175
} else {
175176
where = and(
176-
ne(postsTable.pinnedAt, sql`${null}`),
177+
isNotNull(postsTable.pinnedAt),
177178
eq(postsTable.organizationId, parent.id),
178179
);
179180
}
@@ -192,7 +193,7 @@ Organization.implement({
192193
),
193194
),
194195
),
195-
ne(postsTable.pinnedAt, sql`${null}`),
196+
isNotNull(postsTable.pinnedAt),
196197
eq(postsTable.organizationId, parent.id),
197198
or(
198199
and(
@@ -204,7 +205,7 @@ Organization.implement({
204205
);
205206
} else {
206207
where = and(
207-
ne(postsTable.pinnedAt, sql`${null}`),
208+
isNotNull(postsTable.pinnedAt),
208209
eq(postsTable.organizationId, parent.id),
209210
);
210211
}

src/graphql/types/Organization/pinnedPostsCount.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { and, count, eq, ne, sql } from "drizzle-orm";
1+
import { and, count, eq, isNotNull, ne, sql } from "drizzle-orm";
22
import { postsTable } from "~/src/drizzle/tables/posts";
33
import { TalawaGraphQLError } from "~/src/utilities/TalawaGraphQLError";
44
import envConfig from "~/src/utilities/graphqLimits";
@@ -46,7 +46,7 @@ Organization.implement({
4646
.where(
4747
and(
4848
eq(postsTable.organizationId, parent.id),
49-
ne(postsTable.pinnedAt, sql`${null}`),
49+
isNotNull(postsTable.pinnedAt),
5050
),
5151
),
5252
]);

src/graphql/types/Organization/tagFolders.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
eq,
77
exists,
88
gt,
9+
isNotNull,
910
lt,
1011
or,
1112
sql,
@@ -159,13 +160,13 @@ Organization.implement({
159160
.where(
160161
and(
161162
eq(tagFoldersTable.id, cursor.id),
162-
eq(tagFoldersTable.parentFolderId, sql`${null}`),
163+
isNotNull(tagFoldersTable.parentFolderId),
163164
eq(tagFoldersTable.name, cursor.name),
164165
eq(tagFoldersTable.organizationId, parent.id),
165166
),
166167
),
167168
),
168-
eq(tagFoldersTable.parentFolderId, sql`${null}`),
169+
isNotNull(tagFoldersTable.parentFolderId),
169170
eq(tagFoldersTable.organizationId, parent.id),
170171
or(
171172
and(
@@ -177,7 +178,7 @@ Organization.implement({
177178
);
178179
} else {
179180
where = and(
180-
eq(tagFoldersTable.parentFolderId, sql`${null}`),
181+
isNotNull(tagFoldersTable.parentFolderId),
181182
eq(tagFoldersTable.organizationId, parent.id),
182183
);
183184
}
@@ -191,13 +192,13 @@ Organization.implement({
191192
.where(
192193
and(
193194
eq(tagFoldersTable.id, cursor.id),
194-
eq(tagFoldersTable.parentFolderId, sql`${null}`),
195+
isNotNull(tagFoldersTable.parentFolderId),
195196
eq(tagFoldersTable.name, cursor.name),
196197
eq(tagFoldersTable.organizationId, parent.id),
197198
),
198199
),
199200
),
200-
eq(tagFoldersTable.parentFolderId, sql`${null}`),
201+
isNotNull(tagFoldersTable.parentFolderId),
201202
eq(tagFoldersTable.organizationId, parent.id),
202203
or(
203204
and(
@@ -209,7 +210,7 @@ Organization.implement({
209210
);
210211
} else {
211212
where = and(
212-
eq(tagFoldersTable.parentFolderId, sql`${null}`),
213+
isNotNull(tagFoldersTable.parentFolderId),
213214
eq(tagFoldersTable.organizationId, parent.id),
214215
);
215216
}

src/graphql/types/Post/downVoters.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
eq,
77
exists,
88
gt,
9+
isNotNull,
910
lt,
1011
ne,
1112
or,
@@ -109,15 +110,15 @@ Post.implement({
109110
.from(postVotesTable)
110111
.where(
111112
and(
112-
ne(postVotesTable.creatorId, sql`${null}`),
113+
isNotNull(postVotesTable.creatorId),
113114
eq(postVotesTable.createdAt, cursor.createdAt),
114115
eq(postVotesTable.creatorId, cursor.creatorId),
115116
eq(postVotesTable.postId, parent.id),
116117
eq(postVotesTable.type, "down_vote"),
117118
),
118119
),
119120
),
120-
ne(postVotesTable.creatorId, sql`${null}`),
121+
isNotNull(postVotesTable.creatorId),
121122
eq(postVotesTable.postId, parent.id),
122123
eq(postVotesTable.type, "down_vote"),
123124
or(
@@ -130,7 +131,7 @@ Post.implement({
130131
);
131132
} else {
132133
where = and(
133-
ne(postVotesTable.creatorId, sql`${null}`),
134+
isNotNull(postVotesTable.creatorId),
134135
eq(postVotesTable.postId, parent.id),
135136
eq(postVotesTable.type, "down_vote"),
136137
);
@@ -144,15 +145,15 @@ Post.implement({
144145
.from(postVotesTable)
145146
.where(
146147
and(
147-
ne(postVotesTable.creatorId, sql`${null}`),
148+
isNotNull(postVotesTable.creatorId),
148149
eq(postVotesTable.createdAt, cursor.createdAt),
149150
eq(postVotesTable.creatorId, cursor.creatorId),
150151
eq(postVotesTable.postId, parent.id),
151152
eq(postVotesTable.type, "down_vote"),
152153
),
153154
),
154155
),
155-
ne(postVotesTable.creatorId, sql`${null}`),
156+
isNotNull(postVotesTable.creatorId),
156157
eq(postVotesTable.postId, parent.id),
157158
eq(postVotesTable.type, "down_vote"),
158159
or(
@@ -165,7 +166,7 @@ Post.implement({
165166
);
166167
} else {
167168
where = and(
168-
ne(postVotesTable.creatorId, sql`${null}`),
169+
isNotNull(postVotesTable.creatorId),
169170
eq(postVotesTable.postId, parent.id),
170171
eq(postVotesTable.type, "down_vote"),
171172
);

0 commit comments

Comments
 (0)