This repository has been archived on 2024-11-20. You can view files and clone it, but cannot push or open issues or pull requests.
p61-project/infrastructure/supabase/repositories/GetHabitProgressHistory.ts

25 lines
892 B
TypeScript

import type { GetHabitProgressHistoryRepository } from "@/domain/repositories/GetHabitProgressHistory"
import { SupabaseRepository } from "@/infrastructure/supabase/repositories/_SupabaseRepository"
import { habitProgressHistorySupabaseDTO } from "../data-transfer-objects/HabitProgressDTO"
export class GetHabitProgressHistorySupabaseRepository
extends SupabaseRepository
implements GetHabitProgressHistoryRepository
{
public execute: GetHabitProgressHistoryRepository["execute"] = async (
options,
) => {
const { habit } = options
const { data } = await this.supabaseClient
.from("habits_progresses")
.select("*")
.eq("habit_id", habit.id)
.throwOnError()
const habitProgressHistory = data as NonNullable<typeof data>
return habitProgressHistorySupabaseDTO.fromSupabaseToDomain(
habitProgressHistory,
habit.goal,
)
}
}