From 9f7ea9ca5066322db3e1697cc1d7102fe574aebb Mon Sep 17 00:00:00 2001 From: Sebastien Castiel Date: Mon, 11 Dec 2023 11:39:04 -0500 Subject: [PATCH] README --- LICENSE | 21 ++++++++++++++++++++ README.md | 45 +++++++++++++++++++----------------------- src/app/page.tsx | 10 ---------- src/scripts/migrate.ts | 14 ++++++++----- 4 files changed, 50 insertions(+), 40 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ce9f5f6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License Copyright (c) 2023 Sebastien Castiel + +Permission is hereby granted, +free of charge, to any person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to the +following conditions: + +The above copyright notice and this permission notice +(including the next paragraph) shall be included in all copies or substantial +portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO +EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index c403366..f3cebf3 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,31 @@ -This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). +# [Spliit](https://spliit.app) -## Getting Started +Spliit is a free and open source alternative to Splitwise. I created it back in 2022 as a side project to learn the Go language, but rewrote it with Next.js since. -First, run the development server: +## Features -```bash -npm run dev -# or -yarn dev -# or -pnpm dev -# or -bun dev -``` +- [x] Create a group and share it with friends +- [x] Create expenses with description +- [x] Display group balances +- [x] Create reimbursement expenses +- [x] Progressive Web App -Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. +### Work in progress -You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. +- [ ] Select all/no participant for expenses +- [ ] Tell the application who you are when opening a group -This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font. +## Stack -## Learn More +- [Next.js](https://nextjs.org/) for the web application +- [TailwindCSS](https://tailwindcss.com/) for the styling +- [shadcn/UI](https://ui.shadcn.com/) for the UI components +- [Vercel](https://vercel.com/) for hosting (application and database) -To learn more about Next.js, take a look at the following resources: +## Contribute -- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. -- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. +The project is open to contributions. Feel free to open an issue or even a pull-request! -You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! +## License -## Deploy on Vercel - -The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. - -Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. +MIT, see [LICENSE](./LICENSE). diff --git a/src/app/page.tsx b/src/app/page.tsx index 77dfed0..e1b43e0 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -33,16 +33,6 @@ export default function HomePage() { Create a group - diff --git a/src/scripts/migrate.ts b/src/scripts/migrate.ts index bf7d93c..beeecc1 100644 --- a/src/scripts/migrate.ts +++ b/src/scripts/migrate.ts @@ -10,6 +10,9 @@ async function main() { withClient(async (client) => { const prisma = await getPrisma() + // console.log('Deleting all groups…') + // await prisma.group.deleteMany({}) + const { rows: groupRows } = await client.query<{ id: string name: string @@ -17,6 +20,10 @@ async function main() { created_at: Date }>('select id, name, currency, created_at from groups') + const existingGroups = ( + await prisma.group.findMany({ select: { id: true } }) + ).map((group) => group.id) + for (const groupRow of groupRows) { const participants: Prisma.ParticipantCreateManyInput[] = [] const expenses: Prisma.ExpenseCreateManyInput[] = [] @@ -24,10 +31,7 @@ async function main() { const participantIdsMapping: Record = {} const expenseIdsMapping: Record = {} - const existingGroup = await prisma.group.findUnique({ - where: { id: groupRow.id }, - }) - if (existingGroup) { + if (existingGroups.includes(groupRow.id)) { console.log(`Group ${groupRow.id} already exists, skipping.`) continue } @@ -65,7 +69,7 @@ async function main() { paid_by_participant_id: number is_reimbursement: boolean }>( - 'select id, created_at, description, amount, paid_by_participant_id, is_reimbursement from expenses where group_id = $1::text', + 'select id, created_at, description, amount, paid_by_participant_id, is_reimbursement from expenses where group_id = $1::text and deleted_at is null', [groupRow.id], ) for (const expenseRow of expenseRows) {