Skip to content

Add recordMentionMany() for bulk mention tracking #3

@TickTockBent

Description

@TickTockBent

Problem

When multiple memories are referenced in a single interaction, consumers must call recordMention() for each one:

// Current approach in Jeorge
await Promise.all(memoryIds.map(id => johnny.recordMention(id)))

This results in N separate database calls.

Proposed Solution

Add a recordMentionMany() method for efficient bulk updates:

await johnny.recordMentionMany(['memory-1', 'memory-2', 'memory-3'])

Implementation

Single SQL update with WHERE id IN (...):

async recordMentionMany(ids: string[]): Promise<void> {
  if (ids.length === 0) return
  
  await this.prisma.memory.updateMany({
    where: { id: { in: ids } },
    data: {
      lastMentionedAt: new Date(),
      mentionCount: { increment: 1 },
    },
  })
}

Priority

Low - the current Promise.all approach works fine, this is just a minor optimization.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions