Update groupID in queries and mutations to be a string.
All checks were successful
Main / build-and-push-docker-image (20.x) (push) Successful in 12m1s
All checks were successful
Main / build-and-push-docker-image (20.x) (push) Successful in 12m1s
This commit is contained in:
@@ -33,20 +33,15 @@ export const resolvers = {
|
||||
}),
|
||||
getStatsRange: async (
|
||||
_parent: unknown,
|
||||
data: { startDate: string; endDate: string }
|
||||
data: { startDate: Date; endDate: Date }
|
||||
// _ctx: unknown
|
||||
) => {
|
||||
const { startDate, endDate } = data;
|
||||
|
||||
if (startDate === "" || endDate === "") {
|
||||
return null;
|
||||
}
|
||||
|
||||
return await prisma.dailyStats.findMany({
|
||||
where: {
|
||||
createdAt: {
|
||||
gt: new Date(startDate),
|
||||
lte: new Date(endDate)
|
||||
gt: startDate,
|
||||
lte: endDate
|
||||
}
|
||||
},
|
||||
orderBy: {
|
||||
@@ -65,12 +60,21 @@ export const resolvers = {
|
||||
data: { groupID: number }
|
||||
// _ctx: unknown
|
||||
) => {
|
||||
const { groupID } = data;
|
||||
return await prisma.groups.findUnique({
|
||||
const groupIDInt = BigInt(data.groupID);
|
||||
|
||||
const group = await prisma.groups.findUnique({
|
||||
where: {
|
||||
telegramID: groupID
|
||||
telegramID: groupIDInt
|
||||
}
|
||||
});
|
||||
|
||||
if (group === null) {
|
||||
const groups = await prisma.groups.findMany({
|
||||
orderBy: { name: "asc" }
|
||||
});
|
||||
}
|
||||
|
||||
return group;
|
||||
}
|
||||
},
|
||||
Mutation: {
|
||||
@@ -173,7 +177,7 @@ export const resolvers = {
|
||||
addGroup: async (
|
||||
_parent: unknown,
|
||||
data: {
|
||||
groupID: number;
|
||||
groupID: string;
|
||||
groupName: string;
|
||||
groupUsername: string;
|
||||
mutationKey?: string;
|
||||
@@ -181,6 +185,7 @@ export const resolvers = {
|
||||
// _ctx: unknown
|
||||
) => {
|
||||
const { groupID, groupName, groupUsername, mutationKey } = data;
|
||||
const groupIDInt = BigInt(groupID);
|
||||
|
||||
if (env !== "development") {
|
||||
if (!mutationKey) {
|
||||
@@ -193,7 +198,7 @@ export const resolvers = {
|
||||
}
|
||||
|
||||
const existingGroup = await prisma.groups.findUnique({
|
||||
where: { telegramID: groupID }
|
||||
where: { telegramID: groupIDInt }
|
||||
});
|
||||
|
||||
if (existingGroup !== null) {
|
||||
@@ -214,7 +219,7 @@ export const resolvers = {
|
||||
|
||||
return await prisma.groups.create({
|
||||
data: {
|
||||
telegramID: groupID,
|
||||
telegramID: groupIDInt,
|
||||
name: groupName
|
||||
}
|
||||
});
|
||||
@@ -225,6 +230,7 @@ export const resolvers = {
|
||||
// _ctx: unknown
|
||||
) => {
|
||||
const { groupID, linksDeleted, mutationKey } = data;
|
||||
const groupIDInt = BigInt(groupID);
|
||||
|
||||
if (env !== "development") {
|
||||
if (!mutationKey) {
|
||||
@@ -237,7 +243,7 @@ export const resolvers = {
|
||||
}
|
||||
|
||||
return await prisma.groups.update({
|
||||
where: { telegramID: groupID },
|
||||
where: { telegramID: groupIDInt },
|
||||
data: { linksDeleted: { increment: linksDeleted } }
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user