Skip to content

Commit cb425ce

Browse files
committed
address code review
1 parent ceae283 commit cb425ce

3 files changed

Lines changed: 33 additions & 4 deletions

File tree

client/src/webpages/dashboard/userStrikes/StrikeAnalyticsTab.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,12 @@ function RecentUserStrikeActionsTable() {
215215
?.slice()
216216
?.sort((a, b) => (a.time > b.time ? -1 : a.time < b.time ? 1 : 0))
217217
.map((values) => {
218-
const userId = values.creatorId ?? values.itemId;
219-
const userTypeId = values.creatorTypeId ?? values.itemTypeId;
218+
const creatorIdentity =
219+
values.creatorId && values.creatorTypeId
220+
? { id: values.creatorId, typeId: values.creatorTypeId }
221+
: null;
222+
const userId = creatorIdentity?.id ?? values.itemId;
223+
const userTypeId = creatorIdentity?.typeId ?? values.itemTypeId;
220224
return {
221225
user: (
222226
<Link

server/plugins/warehouse/queries/ClickhouseActionExecutionsAdapter.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,30 @@ describe('ClickhouseActionExecutionsAdapter.getRecentUserStrikeActions', () => {
199199
expect(results[0]?.creatorTypeId).toBeNull();
200200
});
201201

202+
it('returns both creator fields when both are present in the row', async () => {
203+
const ts = '2026-06-01T10:00:00.000Z';
204+
const { adapter } = makeAdapter([
205+
{
206+
ts,
207+
item_id: 'content-1',
208+
item_type_id: 'content-type-A',
209+
item_type_kind: 'CONTENT',
210+
item_creator_id: 'user-5',
211+
item_creator_type_id: null,
212+
action_id: 'action-ban',
213+
action_source: 'user-strike-action-execution',
214+
},
215+
]);
216+
217+
const results = await adapter.getRecentUserStrikeActions({
218+
orgId: 'org-1',
219+
limit: 10,
220+
});
221+
222+
expect(results[0]?.creatorId).toBe('user-5');
223+
expect(results[0]?.creatorTypeId).toBeNull();
224+
});
225+
202226
it('selects item_creator_id and item_creator_type_id in the SQL', async () => {
203227
const { adapter, query } = makeAdapter([]);
204228

server/services/userStrikeService/userStrikeService.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,9 @@ export class UserStrikeService {
266266
actionId: it.actionId,
267267
itemId: it.itemId,
268268
itemTypeId: it.itemTypeId,
269-
creatorId: it.creatorId ?? null,
270-
creatorTypeId: it.creatorTypeId ?? null,
269+
creatorId: it.creatorId && it.creatorTypeId ? it.creatorId : null,
270+
creatorTypeId:
271+
it.creatorId && it.creatorTypeId ? it.creatorTypeId : null,
271272
source: it.source,
272273
time: it.occurredAt,
273274
}

0 commit comments

Comments
 (0)