mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-17 19:49:40 +02:00
Move inactive projects out of active workspace: - bauntown (community website) - maerchenzauber (AI story generation) - memoro (voice memo app) - news (news aggregation) - nutriphi (nutrition tracking) - reader (reading app) - uload (URL shortener) - wisekeep (AI wisdom extraction) Update CLAUDE.md documentation: - Add presi to active projects - Document archived projects section - Update workspace configuration Archived apps can be re-activated by moving back to apps/ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
37 lines
1,010 B
TypeScript
37 lines
1,010 B
TypeScript
import { createAuthClient } from '@/supabase/supabaseClient';
|
|
|
|
/**
|
|
* Optimized query to fetch memos filtered by multiple tags
|
|
* Replaces N+1 query pattern with a single efficient query
|
|
*/
|
|
export async function fetchMemosByTags(tagIds: string[]): Promise<string[]> {
|
|
const supabase = await createAuthClient();
|
|
|
|
// Single query that gets all memos that have ALL the specified tags
|
|
const { data, error } = await supabase.rpc('get_memos_with_all_tags', {
|
|
tag_ids: tagIds,
|
|
});
|
|
|
|
if (error) {
|
|
console.error('Error fetching memos by tags:', error);
|
|
return [];
|
|
}
|
|
|
|
return data || [];
|
|
}
|
|
|
|
/**
|
|
* SQL function to be added to Supabase:
|
|
*
|
|
* CREATE OR REPLACE FUNCTION get_memos_with_all_tags(tag_ids uuid[])
|
|
* RETURNS TABLE(memo_id uuid) AS $$
|
|
* BEGIN
|
|
* RETURN QUERY
|
|
* SELECT DISTINCT mt.memo_id
|
|
* FROM memo_tags mt
|
|
* WHERE mt.tag_id = ANY(tag_ids)
|
|
* GROUP BY mt.memo_id
|
|
* HAVING COUNT(DISTINCT mt.tag_id) = array_length(tag_ids, 1);
|
|
* END;
|
|
* $$ LANGUAGE plpgsql SECURITY DEFINER;
|
|
*/
|