1.2.2
This commit is contained in:
parent
9630968e6f
commit
e4e7841109
4 changed files with 44 additions and 12 deletions
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "sprintpadawan",
|
||||
"version": "1.2.1",
|
||||
"version": "1.2.2",
|
||||
"description": "Plan. Sprint. Repeat.",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
|
|
@ -106,6 +106,14 @@ const AdminBody: React.FC = () => {
|
|||
},
|
||||
});
|
||||
|
||||
const clearSessionsByUserMutation = api.session.deleteAllByUserId.useMutation(
|
||||
{
|
||||
onSuccess: async () => {
|
||||
await refetchData();
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const clearSessionsMutation = api.session.deleteAll.useMutation({
|
||||
onSuccess: async () => {
|
||||
await refetchData();
|
||||
|
@ -122,8 +130,12 @@ const AdminBody: React.FC = () => {
|
|||
await deleteUserMutation.mutateAsync({ userId });
|
||||
};
|
||||
|
||||
const clearSessionsHandler = async (userId: string) => {
|
||||
await clearSessionsMutation.mutateAsync({ userId });
|
||||
const clearSessionsByUserHandler = async (userId: string) => {
|
||||
await clearSessionsByUserMutation.mutateAsync({ userId });
|
||||
};
|
||||
|
||||
const clearSessionsHandler = async () => {
|
||||
await clearSessionsMutation.mutateAsync();
|
||||
};
|
||||
|
||||
const setUserRoleHandler = async (userId: string, role: Role) => {
|
||||
|
@ -184,9 +196,21 @@ const AdminBody: React.FC = () => {
|
|||
votesCountFetching ? (
|
||||
<span className="loading loading-dots loading-lg"></span>
|
||||
) : (
|
||||
<button className="btn btn-primary" onClick={() => void refetchData()}>
|
||||
<>
|
||||
<button
|
||||
className="btn btn-primary"
|
||||
onClick={() => void refetchData()}
|
||||
>
|
||||
Re-fetch
|
||||
</button>
|
||||
|
||||
<button
|
||||
className="btn btn-primary"
|
||||
onClick={() => void clearSessionsHandler()}
|
||||
>
|
||||
Delete All Sessions
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
|
||||
<div className="card max-w-[80vw] bg-neutral shadow-xl m-4">
|
||||
|
@ -258,7 +282,9 @@ const AdminBody: React.FC = () => {
|
|||
</button>
|
||||
<button
|
||||
className="m-2"
|
||||
onClick={() => void clearSessionsHandler(user.id)}
|
||||
onClick={() =>
|
||||
void clearSessionsByUserHandler(user.id)
|
||||
}
|
||||
>
|
||||
<AiOutlineClear className="text-xl inline-block hover:text-warning" />
|
||||
</button>
|
||||
|
|
|
@ -4,7 +4,7 @@ import { env } from "~/env.mjs";
|
|||
import { redis } from "~/server/redis";
|
||||
|
||||
export const sessionRouter = createTRPCRouter({
|
||||
deleteAll: protectedProcedure
|
||||
deleteAllByUserId: protectedProcedure
|
||||
.input(
|
||||
z.object({
|
||||
userId: z.string(),
|
||||
|
@ -21,6 +21,15 @@ export const sessionRouter = createTRPCRouter({
|
|||
await redis.del(`${env.APP_ENV}_kv_userlist_admin`);
|
||||
}
|
||||
|
||||
return !!sessions;
|
||||
}),
|
||||
deleteAll: protectedProcedure.mutation(async ({ ctx, input }) => {
|
||||
const sessions = await ctx.prisma.session.deleteMany();
|
||||
|
||||
if (!!sessions) {
|
||||
await redis.del(`${env.APP_ENV}_kv_userlist_admin`);
|
||||
}
|
||||
|
||||
return !!sessions;
|
||||
}),
|
||||
});
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
import { Redis } from "@upstash/redis";
|
||||
import { env } from "~/env.mjs";
|
||||
import https from "https";
|
||||
|
||||
export const redis = new Redis({
|
||||
url: env.UPSTASH_REDIS_REST_URL,
|
||||
token: env.UPSTASH_REDIS_REST_TOKEN,
|
||||
export const redis = Redis.fromEnv({
|
||||
agent: new https.Agent({ keepAlive: true }),
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue