feat: sort briefs by updated at (#1409)

This commit is contained in:
Ralph Khreish
2025-11-15 12:15:07 +01:00
committed by GitHub
parent 3c6642b251
commit 26f77c207b
7 changed files with 52 additions and 9 deletions

View File

@@ -31,6 +31,7 @@
},
"dependencies": {
"@supabase/supabase-js": "^2.57.4",
"date-fns": "^4.1.0",
"fs-extra": "^11.3.2",
"simple-git": "^3.28.0",
"steno": "^4.0.2",

View File

@@ -50,6 +50,7 @@ export * from './common/errors/index.js';
// Utils
export * from './common/utils/index.js';
export * from './utils/time.utils.js';
// ========== Domain-Specific Type Exports ==========

View File

@@ -3,13 +3,13 @@
* Handles fetching and managing organizations and briefs from the API
*/
import { SupabaseClient } from '@supabase/supabase-js';
import type { SupabaseClient } from '@supabase/supabase-js';
import {
ERROR_CODES,
TaskMasterError
} from '../../../common/errors/task-master-error.js';
import { getLogger } from '../../../common/logger/index.js';
import { Database } from '../../../common/types/database.types.js';
import type { Database } from '../../../common/types/database.types.js';
import type { Brief } from '../../briefs/types.js';
/**
@@ -171,7 +171,8 @@ export class OrganizationService {
title
)
`)
.eq('account_id', orgId);
.eq('account_id', orgId)
.order('updated_at', { ascending: false });
if (error) {
throw new TaskMasterError(

View File

@@ -0,0 +1,18 @@
/**
* @fileoverview Time utilities for formatting relative timestamps
* Shared across CLI, MCP, extension, and other interfaces
*/
import { formatDistanceToNow } from 'date-fns';
/**
* Format a date as relative time from now (e.g., "2 hours ago", "3 days ago")
* @param date - Date string or Date object to format
* @returns Relative time string (e.g., "less than a minute ago", "5 minutes ago", "2 weeks ago")
*/
export function formatRelativeTime(date: string | Date): string {
const dateObj = typeof date === 'string' ? new Date(date) : date;
// Use date-fns for robust formatting with proper edge case handling
return formatDistanceToNow(dateObj, { addSuffix: true });
}