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 (
|
getStatsRange: async (
|
||||||
_parent: unknown,
|
_parent: unknown,
|
||||||
data: { startDate: string; endDate: string }
|
data: { startDate: Date; endDate: Date }
|
||||||
// _ctx: unknown
|
// _ctx: unknown
|
||||||
) => {
|
) => {
|
||||||
const { startDate, endDate } = data;
|
const { startDate, endDate } = data;
|
||||||
|
|
||||||
if (startDate === "" || endDate === "") {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return await prisma.dailyStats.findMany({
|
return await prisma.dailyStats.findMany({
|
||||||
where: {
|
where: {
|
||||||
createdAt: {
|
createdAt: {
|
||||||
gt: new Date(startDate),
|
gt: startDate,
|
||||||
lte: new Date(endDate)
|
lte: endDate
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
orderBy: {
|
orderBy: {
|
||||||
@@ -65,12 +60,21 @@ export const resolvers = {
|
|||||||
data: { groupID: number }
|
data: { groupID: number }
|
||||||
// _ctx: unknown
|
// _ctx: unknown
|
||||||
) => {
|
) => {
|
||||||
const { groupID } = data;
|
const groupIDInt = BigInt(data.groupID);
|
||||||
return await prisma.groups.findUnique({
|
|
||||||
|
const group = await prisma.groups.findUnique({
|
||||||
where: {
|
where: {
|
||||||
telegramID: groupID
|
telegramID: groupIDInt
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (group === null) {
|
||||||
|
const groups = await prisma.groups.findMany({
|
||||||
|
orderBy: { name: "asc" }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return group;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Mutation: {
|
Mutation: {
|
||||||
@@ -173,7 +177,7 @@ export const resolvers = {
|
|||||||
addGroup: async (
|
addGroup: async (
|
||||||
_parent: unknown,
|
_parent: unknown,
|
||||||
data: {
|
data: {
|
||||||
groupID: number;
|
groupID: string;
|
||||||
groupName: string;
|
groupName: string;
|
||||||
groupUsername: string;
|
groupUsername: string;
|
||||||
mutationKey?: string;
|
mutationKey?: string;
|
||||||
@@ -181,6 +185,7 @@ export const resolvers = {
|
|||||||
// _ctx: unknown
|
// _ctx: unknown
|
||||||
) => {
|
) => {
|
||||||
const { groupID, groupName, groupUsername, mutationKey } = data;
|
const { groupID, groupName, groupUsername, mutationKey } = data;
|
||||||
|
const groupIDInt = BigInt(groupID);
|
||||||
|
|
||||||
if (env !== "development") {
|
if (env !== "development") {
|
||||||
if (!mutationKey) {
|
if (!mutationKey) {
|
||||||
@@ -193,7 +198,7 @@ export const resolvers = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const existingGroup = await prisma.groups.findUnique({
|
const existingGroup = await prisma.groups.findUnique({
|
||||||
where: { telegramID: groupID }
|
where: { telegramID: groupIDInt }
|
||||||
});
|
});
|
||||||
|
|
||||||
if (existingGroup !== null) {
|
if (existingGroup !== null) {
|
||||||
@@ -214,7 +219,7 @@ export const resolvers = {
|
|||||||
|
|
||||||
return await prisma.groups.create({
|
return await prisma.groups.create({
|
||||||
data: {
|
data: {
|
||||||
telegramID: groupID,
|
telegramID: groupIDInt,
|
||||||
name: groupName
|
name: groupName
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -225,6 +230,7 @@ export const resolvers = {
|
|||||||
// _ctx: unknown
|
// _ctx: unknown
|
||||||
) => {
|
) => {
|
||||||
const { groupID, linksDeleted, mutationKey } = data;
|
const { groupID, linksDeleted, mutationKey } = data;
|
||||||
|
const groupIDInt = BigInt(groupID);
|
||||||
|
|
||||||
if (env !== "development") {
|
if (env !== "development") {
|
||||||
if (!mutationKey) {
|
if (!mutationKey) {
|
||||||
@@ -237,7 +243,7 @@ export const resolvers = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return await prisma.groups.update({
|
return await prisma.groups.update({
|
||||||
where: { telegramID: groupID },
|
where: { telegramID: groupIDInt },
|
||||||
data: { linksDeleted: { increment: linksDeleted } }
|
data: { linksDeleted: { increment: linksDeleted } }
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -9,19 +9,19 @@ const typeDefs = /* GraphQL */ `
|
|||||||
getTodayStats: DailyStats!
|
getTodayStats: DailyStats!
|
||||||
getStatsRange(startDate: String!, endDate: String!): [DailyStats]
|
getStatsRange(startDate: String!, endDate: String!): [DailyStats]
|
||||||
getTotalStats: TotalStats!
|
getTotalStats: TotalStats!
|
||||||
getGroupStats(groupID: BigInt!): Groups
|
getGroupStats(groupID: String!): Groups
|
||||||
}
|
}
|
||||||
type Mutation {
|
type Mutation {
|
||||||
init(mutationKey: String): String!
|
init(mutationKey: String): String!
|
||||||
cronJob(mutationKey: String): TotalStats!
|
cronJob(mutationKey: String): TotalStats!
|
||||||
addGroup(
|
addGroup(
|
||||||
groupID: BigInt!
|
groupID: String!
|
||||||
groupName: String!
|
groupName: String!
|
||||||
groupUsername: String
|
groupUsername: String
|
||||||
mutationKey: String
|
mutationKey: String
|
||||||
): Groups!
|
): Groups!
|
||||||
incrementGroup(
|
incrementGroup(
|
||||||
groupID: BigInt!
|
groupID: String!
|
||||||
linksDeleted: Int!
|
linksDeleted: Int!
|
||||||
mutationKey: String
|
mutationKey: String
|
||||||
): Groups!
|
): Groups!
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ const config: runtime.GetPrismaClientConfig = {
|
|||||||
"value": "prisma-client"
|
"value": "prisma-client"
|
||||||
},
|
},
|
||||||
"output": {
|
"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
|
"fromEnvVar": null
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
@@ -37,7 +37,7 @@ const config: runtime.GetPrismaClientConfig = {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"previewFeatures": [],
|
"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
|
"isCustomOutput": true
|
||||||
},
|
},
|
||||||
"relativePath": "..",
|
"relativePath": "..",
|
||||||
|
|||||||
Reference in New Issue
Block a user