Skip to content

Commit

Permalink
sorted values
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHolley committed Jan 11, 2025
1 parent ea88b75 commit 1b450b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# HabitKit

[![Build & Publish](https://github.com/MichaelHolley/HabitKit/actions/workflows/nixpacks_publish.yml/badge.svg?branch=main)](https://github.com/MichaelHolley/HabitKit/actions/workflows/nixpacks_publish.yml)

A simple and intuitive app to track, build, and maintain your habits for a better you!

![image](https://github.com/user-attachments/assets/1fcd0733-f82f-474f-a1b5-844f9167aae8)
Expand Down
9 changes: 8 additions & 1 deletion src/lib/server/habit.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import { Prisma } from '@prisma/client';
import { prisma } from './prisma';

export const getHabitForUser = async (id: string, userId: string) => {
return await prisma.habit.findUnique({
let habit = await prisma.habit.findUnique({
where: {
id: id,
userId: userId
}
});

if (!habit) return null;

habit = { ...habit, dates: (habit.dates as Prisma.JsonArray).sort().reverse() };

return habit;
};

export const getUserHabits = async (userId: string) => {
Expand Down

0 comments on commit 1b450b2

Please sign in to comment.