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