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 } }
|
||||
});
|
||||
},
|
||||
|
||||
@@ -9,19 +9,19 @@ const typeDefs = /* GraphQL */ `
|
||||
getTodayStats: DailyStats!
|
||||
getStatsRange(startDate: String!, endDate: String!): [DailyStats]
|
||||
getTotalStats: TotalStats!
|
||||
getGroupStats(groupID: BigInt!): Groups
|
||||
getGroupStats(groupID: String!): Groups
|
||||
}
|
||||
type Mutation {
|
||||
init(mutationKey: String): String!
|
||||
cronJob(mutationKey: String): TotalStats!
|
||||
addGroup(
|
||||
groupID: BigInt!
|
||||
groupID: String!
|
||||
groupName: String!
|
||||
groupUsername: String
|
||||
mutationKey: String
|
||||
): Groups!
|
||||
incrementGroup(
|
||||
groupID: BigInt!
|
||||
groupID: String!
|
||||
linksDeleted: Int!
|
||||
mutationKey: String
|
||||
): Groups!
|
||||
|
||||
@@ -23,7 +23,7 @@ const config: runtime.GetPrismaClientConfig = {
|
||||
"value": "prisma-client"
|
||||
},
|
||||
"output": {
|
||||
"value": "/home/lucid/work/WKC/no-twitter-bot-stats/src/prisma/generated",
|
||||
"value": "/home/lucid/work/cove-gitea/no-twitter-bot-stats/src/prisma/generated",
|
||||
"fromEnvVar": null
|
||||
},
|
||||
"config": {
|
||||
@@ -37,7 +37,7 @@ const config: runtime.GetPrismaClientConfig = {
|
||||
}
|
||||
],
|
||||
"previewFeatures": [],
|
||||
"sourceFilePath": "/home/lucid/work/WKC/no-twitter-bot-stats/src/prisma/schema.prisma",
|
||||
"sourceFilePath": "/home/lucid/work/cove-gitea/no-twitter-bot-stats/src/prisma/schema.prisma",
|
||||
"isCustomOutput": true
|
||||
},
|
||||
"relativePath": "..",
|
||||
|
||||
Reference in New Issue
Block a user