Skip to content

Commit 9255156

Browse files
committed
fix: normalize member identity values in cleanup script
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
1 parent e944bda commit 9255156

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

backend/src/bin/scripts/cleanup-same-member-case-variant-identities.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import commandLineArgs from 'command-line-args'
22

3-
import { isEmail } from '@crowd/common'
3+
import { normalizeMemberIdentityValue } from '@crowd/common'
44
import { pgpQx } from '@crowd/data-access-layer'
55
import { getDbConnection } from '@crowd/data-access-layer/src/database'
66
import { QueryExecutor } from '@crowd/data-access-layer/src/queryExecutor'
@@ -166,29 +166,29 @@ setImmediate(async () => {
166166
afterId = candidates[candidates.length - 1].id
167167

168168
for (const row of candidates) {
169-
const lowerValue = row.value.trim().toLowerCase()
169+
const normalized = normalizeMemberIdentityValue(row.value)
170170

171-
if (isEmail(lowerValue) && lowerValue !== row.value) {
171+
if (normalized !== row.value) {
172172
if (testRun) {
173173
log.info(
174174
{
175175
memberId: row.memberId,
176176
platform: row.platform,
177177
type: row.type,
178178
from: row.value,
179-
to: lowerValue,
179+
to: normalized,
180180
},
181181
'Lowercasing email-shaped identity!',
182182
)
183183
}
184184

185185
const { updatedCount, ar } = await qx.tx(async (tx) => {
186-
const updatedCount = await lowercaseIdentityValue(tx, row.id, lowerValue)
186+
const updatedCount = await lowercaseIdentityValue(tx, row.id, normalized)
187187
const ar = await rewriteActivityRelationUsernamesToLower(
188188
tx,
189189
row.memberId,
190190
row.platform,
191-
lowerValue,
191+
normalized,
192192
)
193193
return { updatedCount, ar }
194194
})

0 commit comments

Comments
 (0)