Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions backend/shared/src/notifications/create-new-post-notif.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export const createNewPostFromFollowedUserNotification = async (
? await getAllUserIds(pg)
: await getUserFollowerIds(creator.id, pg)

const sourceText = richTextToString(post.content).slice(0, 200)

if (isAnnouncement) {
for (const userId of followerIds) {
const notification: Notification = {
Expand All @@ -40,7 +42,7 @@ export const createNewPostFromFollowedUserNotification = async (
sourceUserName: creator.name,
sourceUserUsername: creator.username,
sourceUserAvatarUrl: creator.avatarUrl,
sourceText: richTextToString(post.content),
sourceText,
sourceSlug: `post/${post.slug}`,
sourceTitle: post.title,
}
Expand Down Expand Up @@ -76,7 +78,7 @@ export const createNewPostFromFollowedUserNotification = async (
sourceUserName: creator.name,
sourceUserUsername: creator.username,
sourceUserAvatarUrl: creator.avatarUrl,
sourceText: richTextToString(post.content).slice(0, 200),
sourceText,
sourceSlug: `post/${post.slug}`,
sourceTitle: post.title,
}
Expand Down
12 changes: 9 additions & 3 deletions backend/shared/src/supabase/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sortBy } from 'lodash'
import { chunk, sortBy } from 'lodash'
import { pgp, SupabaseDirectClient } from './init'
import { Column, DataFor, Row, TableName, Tables } from 'common/supabase/utils'

Expand Down Expand Up @@ -50,8 +50,14 @@ export async function bulkInsert<
if (values.length == 0) {
return []
}
const query = bulkInsertQuery(table, values)
return await db.many<Row<T>>(query)
const batches = chunk(values, 25000)
const results: Row<T>[] = []
for (const batch of batches) {
const query = bulkInsertQuery(table, batch)
const rows = await db.many<Row<T>>(query)
results.push(...rows)
}
return results
}

export async function update<
Expand Down