<commit_before>/* Copyright 2017 Vector Creations Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

CREATE TABLE groups (
    group_id TEXT NOT NULL,
    name TEXT,
    avatar_url TEXT,
    short_description TEXT,
    long_description TEXT
);

CREATE UNIQUE INDEX groups_idx ON groups(group_id);


-- list of users the group server thinks are joined
CREATE TABLE group_users (
    group_id TEXT NOT NULL,
    user_id TEXT NOT NULL,
    is_admin BOOLEAN NOT NULL,  -- whether the users membership can be seen by everyone
    is_public BOOLEAN NOT NULL
);


CREATE INDEX groups_users_g_idx ON group_users(group_id, user_id);
CREATE INDEX groups_users_u_idx ON group_users(user_id);

-- list of users the group server thinks are invited
CREATE TABLE group_invites (
    group_id TEXT NOT NULL,
    user_id TEXT NOT NULL
);

CREATE INDEX groups_invites_g_idx ON group_invites(group_id, user_id);
CREATE INDEX groups_invites_u_idx ON group_invites(user_id);


CREATE TABLE group_rooms (
    group_id TEXT NOT NULL,
    room_id TEXT NOT NULL,
    is_public BOOLEAN NOT NULL  -- whether the room can be seen by everyone
);

CREATE INDEX groups_rooms_g_idx ON group_rooms(group_id, room_id);
CREATE INDEX groups_rooms_r_idx ON group_rooms(room_id);


-- List of  attestations we've given out and need to renew
CREATE TABLE group_attestations_renewals (
    group_id TEXT NOT NULL,
    user_id TEXT NOT NULL,
    valid_until_ms BIGINT NOT NULL
);

CREATE INDEX group_attestations_renewals_g_idx ON group_attestations_renewals(group_id, user_id);
CREATE INDEX group_attestations_renewals_u_idx ON group_attestations_renewals(user_id);
CREATE INDEX group_attestations_renewals_v_idx ON group_attestations_renewals(valid_until_ms);


-- List of attestations we've received from remotes and are interested in.
CREATE TABLE group_attestations_remote (
    group_id TEXT NOT NULL,
    user_id TEXT NOT NULL,
    valid_until_ms BIGINT NOT NULL,
    attestation_json TEXT NOT NULL
);

CREATE INDEX group_attestations_remote_g_idx ON group_attestations_remote(group_id, user_id);
CREATE INDEX group_attestations_remote_u_idx ON group_attestations_remote(user_id);
CREATE INDEX group_attestations_remote_v_idx ON group_attestations_remote(valid_until_ms);
<commit_msg>Move comment<commit_after>/* Copyright 2017 Vector Creations Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

CREATE TABLE groups (
    group_id TEXT NOT NULL,
    name TEXT,
    avatar_url TEXT,
    short_description TEXT,
    long_description TEXT
);

CREATE UNIQUE INDEX groups_idx ON groups(group_id);


-- list of users the group server thinks are joined
CREATE TABLE group_users (
    group_id TEXT NOT NULL,
    user_id TEXT NOT NULL,
    is_admin BOOLEAN NOT NULL,
    is_public BOOLEAN NOT NULL  -- whether the users membership can be seen by everyone
);


CREATE INDEX groups_users_g_idx ON group_users(group_id, user_id);
CREATE INDEX groups_users_u_idx ON group_users(user_id);

-- list of users the group server thinks are invited
CREATE TABLE group_invites (
    group_id TEXT NOT NULL,
    user_id TEXT NOT NULL
);

CREATE INDEX groups_invites_g_idx ON group_invites(group_id, user_id);
CREATE INDEX groups_invites_u_idx ON group_invites(user_id);


CREATE TABLE group_rooms (
    group_id TEXT NOT NULL,
    room_id TEXT NOT NULL,
    is_public BOOLEAN NOT NULL  -- whether the room can be seen by everyone
);

CREATE INDEX groups_rooms_g_idx ON group_rooms(group_id, room_id);
CREATE INDEX groups_rooms_r_idx ON group_rooms(room_id);


-- List of  attestations we've given out and need to renew
CREATE TABLE group_attestations_renewals (
    group_id TEXT NOT NULL,
    user_id TEXT NOT NULL,
    valid_until_ms BIGINT NOT NULL
);

CREATE INDEX group_attestations_renewals_g_idx ON group_attestations_renewals(group_id, user_id);
CREATE INDEX group_attestations_renewals_u_idx ON group_attestations_renewals(user_id);
CREATE INDEX group_attestations_renewals_v_idx ON group_attestations_renewals(valid_until_ms);


-- List of attestations we've received from remotes and are interested in.
CREATE TABLE group_attestations_remote (
    group_id TEXT NOT NULL,
    user_id TEXT NOT NULL,
    valid_until_ms BIGINT NOT NULL,
    attestation_json TEXT NOT NULL
);

CREATE INDEX group_attestations_remote_g_idx ON group_attestations_remote(group_id, user_id);
CREATE INDEX group_attestations_remote_u_idx ON group_attestations_remote(user_id);
CREATE INDEX group_attestations_remote_v_idx ON group_attestations_remote(valid_until_ms);

{'fraction_non_alphanumeric': 0.048833423765599564, 'fraction_numerical': 0.0028938325194429373, 'mean_word_length': 4.712809917355372, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5037617', 'n_tokens_mistral': 1698, 'n_tokens_neox': 1659, 'n_words': 611}