2024-01-11 21:37:53 +08:00
|
|
|
import { gql } from '@apollo/client';
|
|
|
|
|
|
|
|
export interface GetHasCurrentPresentationResponse {
|
|
|
|
pres_page_aggregate: {
|
|
|
|
aggregate: {
|
|
|
|
count: number;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-01-17 23:45:52 +08:00
|
|
|
export interface UserInfo {
|
|
|
|
user: {
|
|
|
|
name: string;
|
|
|
|
userId: string;
|
|
|
|
};
|
|
|
|
optionDescIds: Array<string>;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface ResponseInfo {
|
|
|
|
optionResponsesCount: number;
|
|
|
|
optionDesc: string;
|
|
|
|
pollResponsesCount: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface PollInfo {
|
|
|
|
published: boolean;
|
|
|
|
pollId: string;
|
|
|
|
secret: boolean;
|
|
|
|
questionText: string;
|
|
|
|
ended: boolean;
|
|
|
|
multipleResponses: boolean;
|
|
|
|
users: Array<UserInfo>;
|
|
|
|
responses: Array<ResponseInfo>;
|
2024-01-25 01:42:38 +08:00
|
|
|
users_aggregate: {
|
|
|
|
aggregate: {
|
|
|
|
count: number;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
responses_aggregate: {
|
|
|
|
aggregate: {
|
|
|
|
count: number;
|
|
|
|
sum: {
|
|
|
|
optionResponsesCount: number;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
2024-01-17 23:45:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface getCurrentPollDataResponse {
|
|
|
|
poll: Array<PollInfo>;
|
|
|
|
}
|
|
|
|
|
2024-01-11 21:37:53 +08:00
|
|
|
export const getHasCurrentPresentation = gql`
|
2024-01-17 23:45:52 +08:00
|
|
|
subscription getHasCurrentPresentation {
|
|
|
|
pres_page_aggregate(where: {isCurrentPage: {_eq: true}}) {
|
|
|
|
aggregate {
|
|
|
|
count
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export const getCurrentPollData = gql`
|
|
|
|
subscription getCurrentPollData {
|
2024-01-25 01:42:38 +08:00
|
|
|
poll(order_by: {createdAt: desc}, limit: 1,) {
|
2024-01-17 23:45:52 +08:00
|
|
|
pollId
|
|
|
|
published
|
|
|
|
secret
|
|
|
|
questionText
|
|
|
|
ended
|
|
|
|
multipleResponses
|
|
|
|
users(where: {responded: {_eq: true}}) {
|
|
|
|
user {
|
|
|
|
name
|
|
|
|
userId
|
|
|
|
}
|
|
|
|
optionDescIds
|
|
|
|
}
|
|
|
|
responses {
|
|
|
|
optionResponsesCount
|
|
|
|
optionDesc
|
|
|
|
pollResponsesCount
|
|
|
|
}
|
2024-01-25 01:42:38 +08:00
|
|
|
users_aggregate {
|
|
|
|
aggregate {
|
|
|
|
count
|
|
|
|
}
|
|
|
|
}
|
|
|
|
responses_aggregate {
|
|
|
|
aggregate {
|
|
|
|
count
|
|
|
|
sum {
|
|
|
|
optionResponsesCount
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-01-11 21:37:53 +08:00
|
|
|
}
|
|
|
|
}
|
2024-01-17 23:45:52 +08:00
|
|
|
`;
|
2024-01-11 21:37:53 +08:00
|
|
|
|
|
|
|
export default {
|
|
|
|
getHasCurrentPresentation,
|
|
|
|
};
|