feat: add stars field to comments

This commit is contained in:
Riccardo Senica
2025-01-19 21:06:15 +00:00
parent 89a20c214b
commit 7c1e3989a5
6 changed files with 10 additions and 4 deletions

View File

@@ -130,10 +130,11 @@ export async function diaryCommand(
}
case 'daylog': {
const stars = parsedCommand.flags.stars as number;
const text = parsedCommand.flags.text as string;
const date = (parsedCommand.flags.date as Date) || new Date();
return processDayLog(text, date);
return processDayLog(stars, text, date);
}
default:

View File

@@ -141,6 +141,7 @@ export const diaryCommands: CommandDefinition[] = [
{
name: 'daylog',
flags: [
{ name: 'stars', type: 'number', required: true },
{ name: 'text', type: 'string', required: true },
{ name: 'date', type: 'date', required: false }
]

View File

@@ -3,6 +3,7 @@ import prisma from '@prisma/prisma';
import { ShortcutsResponse } from '@utils/types';
export async function processDayLog(
stars: number,
text: string,
date?: Date
): Promise<ShortcutsResponse> {
@@ -11,6 +12,7 @@ export async function processDayLog(
normalizedDate.setUTCHours(0, 0, 0, 0);
const newComment: Prisma.JsonObject = {
stars,
text,
timestamp: new Date().toISOString()
};

View File

@@ -200,6 +200,7 @@ export class ExpenseReporter {
<tr>
<th>ID</th>
<th>Date</th>
<th>Stars</th>
<th>Log</th>
</tr>
${dayLogs.dayLogs
@@ -213,6 +214,7 @@ export class ExpenseReporter {
<tr>
<td>${dl.id}</td>
<td>${formatDate(dl.createdAt)}</td>
<td>${'✪'.repeat(comment.stars)}</td>
<td>${comment.text}</td>
</tr>
`