Merge pull request #18355 from gustavotrott/graphql-echo-test-running-flag

graphql: Introduces a new flag isRunningEchoTest
This commit is contained in:
Gustavo Trott 2023-07-21 17:21:22 -03:00 committed by GitHub
commit fdd9182e69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 4 deletions

View File

@ -1,14 +1,36 @@
import {gql, useQuery} from '@apollo/client';
import {gql, useMutation, useQuery, useSubscription} from '@apollo/client';
import React from "react";
export default function MyInfo() {
const { loading, error, data } = useQuery(
gql`query {
//where is not necessary once user can update only its own status
//Hasura accepts "now()" as value to timestamp fields
const [updateUserClientEchoTestRunningAtMeAsNow] = useMutation(gql`
mutation UpdateUserClientEchoTestRunningAt {
update_user_current(
where: {}
_set: { echoTestRunningAt: "now()" }
) {
affected_rows
}
}
`);
const handleUpdateUserEchoTestRunningAt = () => {
updateUserClientEchoTestRunningAtMeAsNow();
};
const { loading, error, data } = useSubscription(
gql`subscription {
user_current {
userId
name
meeting {
name
}
echoTestRunningAt
isRunningEchoTest
}
}`
);
@ -24,6 +46,8 @@ export default function MyInfo() {
<th>userId</th>
<th>name</th>
<th>Meeting</th>
<th>echoTestRunningAt</th>
<th>isRunningEchoTest</th>
</tr>
</thead>
<tbody>
@ -34,6 +58,10 @@ export default function MyInfo() {
<td>{curr.userId}</td>
<td>{curr.name}</td>
<td>{curr.meeting.name}</td>
<td>{curr.echoTestRunningAt}
<button onClick={() => handleUpdateUserEchoTestRunningAt()}>Set running now!</button>
</td>
<td>{curr.isRunningEchoTest ? 'Yes' : 'No'}</td>
</tr>
);
})}

View File

@ -286,7 +286,8 @@ CREATE TABLE "user" (
"pinned" bool,
"locked" bool,
"speechLocale" varchar(255),
"hasDrawPermissionOnCurrentPage" bool default FALSE
"hasDrawPermissionOnCurrentPage" bool default FALSE,
"echoTestRunningAt" timestamp
);
CREATE INDEX "idx_user_meetingId" ON "user"("meetingId");
CREATE INDEX "idx_user_extId" ON "user"("meetingId", "extId");
@ -373,6 +374,7 @@ AS SELECT "user"."userId",
"user"."pinned",
"user"."locked",
"user"."speechLocale",
CASE WHEN "user"."echoTestRunningAt" > current_timestamp - INTERVAL '3 seconds' THEN TRUE ELSE FALSE END "isRunningEchoTest",
"user"."hasDrawPermissionOnCurrentPage",
CASE WHEN "user"."role" = 'MODERATOR' THEN true ELSE false END "isModerator",
CASE WHEN "user"."joined" IS true AND "user"."expired" IS false AND "user"."loggedOut" IS false THEN true ELSE false END "isOnline"
@ -423,6 +425,8 @@ AS SELECT "user"."userId",
"user"."locked",
"user"."speechLocale",
"user"."hasDrawPermissionOnCurrentPage",
"user"."echoTestRunningAt",
CASE WHEN "user"."echoTestRunningAt" > current_timestamp - INTERVAL '3 seconds' THEN TRUE ELSE FALSE END "isRunningEchoTest",
CASE WHEN "user"."role" = 'MODERATOR' THEN true ELSE false END "isModerator"
FROM "user";

View File

@ -85,6 +85,7 @@ select_permissions:
- isDialIn
- isModerator
- isOnline
- isRunningEchoTest
- joined
- locked
- loggedOut

View File

@ -119,6 +119,7 @@ select_permissions:
- clientType
- color
- disconnected
- echoTestRunningAt
- ejectReason
- ejectReasonCode
- ejected
@ -129,6 +130,7 @@ select_permissions:
- hasDrawPermissionOnCurrentPage
- isDialIn
- isModerator
- isRunningEchoTest
- joined
- locked
- loggedOut
@ -147,3 +149,15 @@ select_permissions:
_eq: X-Hasura-MeetingId
- userId:
_eq: X-Hasura-UserId
update_permissions:
- role: bbb_client
permission:
columns:
- echoTestRunningAt
filter:
_and:
- meetingId:
_eq: X-Hasura-MeetingId
- userId:
_eq: X-Hasura-UserId
check: null