-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#93 Adding the basic dashboard and authentication mechanism
- Loading branch information
Showing
5 changed files
with
165 additions
and
70 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
prisma/migrations/20240630211113_removing_the_unused_next_js_auth_schema/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the `Account` table. If the table is not empty, all the data it contains will be lost. | ||
- You are about to drop the `Authenticator` table. If the table is not empty, all the data it contains will be lost. | ||
- You are about to drop the `Session` table. If the table is not empty, all the data it contains will be lost. | ||
- You are about to drop the `User` table. If the table is not empty, all the data it contains will be lost. | ||
- You are about to drop the `VerificationToken` table. If the table is not empty, all the data it contains will be lost. | ||
*/ | ||
-- DropForeignKey | ||
ALTER TABLE "Account" DROP CONSTRAINT "Account_userId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "Authenticator" DROP CONSTRAINT "Authenticator_userId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "Session" DROP CONSTRAINT "Session_userId_fkey"; | ||
|
||
-- DropTable | ||
DROP TABLE "Account"; | ||
|
||
-- DropTable | ||
DROP TABLE "Authenticator"; | ||
|
||
-- DropTable | ||
DROP TABLE "Session"; | ||
|
||
-- DropTable | ||
DROP TABLE "User"; | ||
|
||
-- DropTable | ||
DROP TABLE "VerificationToken"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import prisma from '@/app/api/utils/prisma'; | ||
import { Card } from 'flowbite-react'; | ||
|
||
export default function AssistantMetrics() { | ||
const getAssistantCount = async function() { | ||
let total = await prisma.assistant.aggregate({ | ||
_count: { | ||
id: true | ||
} | ||
}) | ||
|
||
return total._count.id | ||
} | ||
|
||
const getThreadCount = async function() { | ||
let total = await prisma.thread.aggregate({ | ||
_count: { | ||
id: true | ||
} | ||
}) | ||
|
||
return total._count.id | ||
} | ||
|
||
const getMessageCount = async function() { | ||
let total = await prisma.message.aggregate({ | ||
_count: { | ||
id: true | ||
} | ||
}) | ||
|
||
return total._count.id | ||
} | ||
|
||
return ( | ||
<div className={'grid xs:grid-flow-row sm:grid-flow-col gap-4'}> | ||
<Card className="flex flex-auto"> | ||
<h5 className="text-lg tracking-tight text-gray-400 dark:text-white"> | ||
Assistants | ||
</h5> | ||
<p className="text-7xl text-gray-700 dark:text-gray-400"> | ||
{getAssistantCount()} | ||
</p> | ||
</Card> | ||
<Card className="flex flex-auto"> | ||
<h5 className="text-lg tracking-tight text-gray-400 dark:text-white"> | ||
Threads | ||
</h5> | ||
<p className="text-7xl text-gray-700 dark:text-gray-400"> | ||
{getThreadCount()} | ||
</p> | ||
</Card> | ||
<Card className="flex flex-auto"> | ||
<h5 className="text-lg tracking-tight text-gray-400 dark:text-white"> | ||
Messages | ||
</h5> | ||
<p className="text-7xl text-gray-700 dark:text-gray-400"> | ||
{getMessageCount()} | ||
</p> | ||
</Card> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import prisma from '@/app/api/utils/prisma'; | ||
import { Card } from 'flowbite-react'; | ||
|
||
export default function UserMetrics() { | ||
const getUserCount = async function() { | ||
let total = await prisma.organization.aggregate({ | ||
where: { | ||
ownerType: { | ||
in: ['personal'], | ||
}, | ||
}, | ||
_count: { | ||
owner: true | ||
} | ||
}) | ||
|
||
return total._count.owner | ||
} | ||
|
||
const getOrganizationCount = async function() { | ||
let total = await prisma.organization.aggregate({ | ||
where: { | ||
ownerType: { | ||
notIn: ['personal'], | ||
}, | ||
}, | ||
_count: { | ||
owner: true | ||
} | ||
}) | ||
|
||
return total._count.owner | ||
} | ||
|
||
return ( | ||
<div className={'grid xs:grid-flow-row sm:grid-flow-col gap-4'}> | ||
<Card className="flex flex-auto"> | ||
<h5 className="text-lg tracking-tight text-gray-400 dark:text-white"> | ||
Users | ||
</h5> | ||
<p className="text-7xl text-gray-700 dark:text-gray-400"> | ||
{getUserCount()} | ||
</p> | ||
</Card> | ||
<Card className="flex flex-auto"> | ||
<h5 className="text-lg tracking-tight text-gray-400 dark:text-white"> | ||
Organizations | ||
</h5> | ||
<p className="text-7xl text-gray-700 dark:text-gray-400"> | ||
{getOrganizationCount()} | ||
</p> | ||
</Card> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters