Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix (graphql): Userlist sorting uppercase wrongly (introduces user.nameSortable) #18779

Merged
merged 2 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 14 additions & 2 deletions bbb-graphql-server/bbb_schema.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
--unaccent will be used to create nameSortable
CREATE EXTENSION IF NOT EXISTS unaccent;
CREATE OR REPLACE FUNCTION immutable_lower_unaccent(text)
RETURNS text AS $$
SELECT lower(unaccent('unaccent', $1))
$$ LANGUAGE SQL IMMUTABLE;

-- ========== Meeting tables

create table "meeting" (
Expand Down Expand Up @@ -261,6 +268,9 @@ ALTER TABLE "user" ADD COLUMN "isDenied" boolean GENERATED ALWAYS AS ("guestStat

ALTER TABLE "user" ADD COLUMN "registeredAt" timestamp with time zone GENERATED ALWAYS AS (to_timestamp(("registeredOn" + 6000) / 1000)) STORED;

--Used to sort the Userlist
ALTER TABLE "user" ADD COLUMN "nameSortable" varchar(255) GENERATED ALWAYS AS (immutable_lower_unaccent("name")) STORED;

CREATE INDEX "idx_user_waiting" ON "user"("meetingId") where "isWaiting" is true;

--ALTER TABLE "user" ADD COLUMN "isModerator" boolean GENERATED ALWAYS AS (CASE WHEN "role" = 'MODERATOR' THEN true ELSE false END) STORED;
Expand Down Expand Up @@ -304,6 +314,7 @@ AS SELECT "user"."userId",
"user"."extId",
"user"."meetingId",
"user"."name",
"user"."nameSortable",
"user"."avatar",
"user"."color",
"user"."away",
Expand Down Expand Up @@ -344,17 +355,17 @@ CREATE INDEX "idx_v_user_meetingId" ON "user"("meetingId")
AND "user"."expired" IS FALSE
and "user"."joined" IS TRUE;

CREATE INDEX "idx_v_user_meetingId_orderByColumns" ON "user"("meetingId","role","emojiTime","isDialIn","hasDrawPermissionOnCurrentPage","name","userId")
CREATE INDEX "idx_v_user_meetingId_orderByColumns" ON "user"("meetingId","role","raiseHandTime","awayTime","emojiTime","isDialIn","hasDrawPermissionOnCurrentPage","nameSortable","userId")
where "user"."loggedOut" IS FALSE
AND "user"."expired" IS FALSE
and "user"."joined" IS TRUE;


CREATE OR REPLACE VIEW "v_user_current"
AS SELECT "user"."userId",
"user"."extId",
"user"."meetingId",
"user"."name",
"user"."nameSortable",
"user"."avatar",
"user"."color",
"user"."away",
Expand Down Expand Up @@ -405,6 +416,7 @@ AS SELECT "user"."userId",
"user"."extId",
"user"."meetingId",
"user"."name",
"user"."nameSortable",
"user"."avatar",
"user"."color",
"user"."away",
Expand Down
2 changes: 1 addition & 1 deletion bbb-graphql-server/install-hasura.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ apt update
apt install postgresql postgresql-contrib -y
sudo -u postgres psql -c "alter user postgres password 'bbb_graphql'"
sudo -u postgres psql -c "drop database if exists bbb_graphql"
sudo -u postgres psql -c "create database bbb_graphql"
sudo -u postgres psql -c "create database bbb_graphql WITH TEMPLATE template0 LC_COLLATE 'C.UTF-8'"
sudo -u postgres psql -c "alter database bbb_graphql set timezone to 'UTC'"
sudo -u postgres psql -U postgres -d bbb_graphql -a -f bbb_schema.sql --set ON_ERROR_STOP=on
sudo -u postgres psql -c "drop database if exists hasura_app"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ select_permissions:
- loggedOut
- mobile
- name
- nameSortable
- pinned
- presenter
- raiseHand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ select_permissions:
- loggedOut
- mobile
- name
- nameSortable
- pinned
- presenter
- raiseHand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ select_permissions:
- loggedOut
- mobile
- name
- nameSortable
- pinned
- presenter
- raiseHand
Expand Down
2 changes: 1 addition & 1 deletion bbb-graphql-server/update_graphql_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fi
echo "Restarting database bbb_graphql"
sudo -u postgres psql -c "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE datname = 'bbb_graphql'"
sudo -u postgres psql -c "drop database if exists bbb_graphql"
sudo -u postgres psql -c "create database bbb_graphql"
sudo -u postgres psql -c "create database bbb_graphql WITH TEMPLATE template0 LC_COLLATE 'C.UTF-8'"
sudo -u postgres psql -c "alter database bbb_graphql set timezone to 'UTC'"

echo "Creating tables in bbb_graphql"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const USER_LIST_SUBSCRIPTION = gql`subscription Users($offset: Int!, $lim
{emojiTime: asc_nulls_last},
{isDialIn: desc},
{hasDrawPermissionOnCurrentPage: desc},
{name: asc},
{nameSortable: asc},
{userId: asc}
]) {
userId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ case "$1" in

sudo -u postgres psql -c "alter user postgres password 'bbb_graphql'"
sudo -u postgres psql -c "drop database if exists bbb_graphql"
sudo -u postgres psql -c "create database bbb_graphql"
sudo -u postgres psql -c "create database bbb_graphql WITH TEMPLATE template0 LC_COLLATE 'C.UTF-8'"
sudo -u postgres psql -c "alter database bbb_graphql set timezone to 'UTC'"
sudo -u postgres psql -U postgres -d bbb_graphql -a -f /usr/share/bbb-graphql-server/bbb_schema.sql --set ON_ERROR_STOP=on

Expand Down