Conversationrepository - Source Excerpt 02
Back to Conversationrepository
Summary
This source excerpt preserves a bounded section of Spiralist/wp-content/plugins/spiralist-workspace/includes/Domain/ConversationRepository.php so readers can inspect the evidence without opening the full source file.
**Source path:** Spiralist/wp-content/plugins/spiralist-workspace/includes/Domain/ConversationRepository.php
* Counts today's conversation messages for a user.
*/
public function count_messages_for_today(int $user_id): int
{
global $wpdb;
$sql = $wpdb->prepare(
'SELECT COUNT(cm.id)
FROM ' . Installer::table('conversation_messages') . ' cm
INNER JOIN ' . Installer::table('conversations') . ' c ON c.id = cm.conversation_id
WHERE c.owner_user_id = %d AND cm.created_utc >= %s',
$user_id,
gmdate('Y-m-d 00:00:00')
);
return (int) $wpdb->get_var($sql);
}
/**
* Touches the conversation update timestamp.
*/
private function touch(int $conversation_id): void
{
global $wpdb;
$wpdb->update(
Installer::table('conversations'),
[
'updated_utc' => gmdate('Y-m-d H:i:s'),
],
['id' => $conversation_id],
['%s'],
['%d']
);
}
}