Skip to content

Commit

Permalink
remove banner (#537)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-8 authored Feb 24, 2025
1 parent 29999ec commit 9c18975
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 122 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,22 @@ import { fileURLToPath } from 'node:url'
import type { IHelper, IInvite } from '@living-dictionaries/types/invite.interface'
import type { Citation, IAbout, IGrammar, Partner } from '@living-dictionaries/types/dictionary.interface'
import { db } from '../config-firebase'
import { admin_supabase, environment, postgres } from '../config-supabase'
import { reset_local_db } from '../reset-local-db'
import { sql_file_string } from '../import/to-sql-string'
import { jacob_ld_user_id } from '../constants'
import { sync_users_across_and_write_fb_sb_mappings, write_users_to_disk } from './users'
import { admin_supabase, postgres } from '../config-supabase'
import { load_fb_to_sb_user_ids } from './get-user-id'
import { generate_inserts } from './generate-inserts'

migrate_the_rest()

async function migrate_the_rest() {
if (environment === 'dev') {
await reset_local_db()
}
// if (environment === 'dev') {
// await reset_local_db()
// }
// if (environment === 'prod') {
// await save_dictionaries()
// await save_dictionaries() // just do once
// }
await write_users_to_disk() // just do once when testing, and once when final run
await sync_users_across_and_write_fb_sb_mappings() // needs run twice, first to sync users, then to save them to disk
await sync_users_across_and_write_fb_sb_mappings() // needs run twice, first to sync users, then to save them to disk
// await write_users_to_disk() // just do once
// await sync_users_across_and_write_fb_sb_mappings() // needs run twice, first to sync users, then to save them to disk
// await sync_users_across_and_write_fb_sb_mappings() // needs run twice, first to sync users, then to save them to disk
await load_fb_to_sb_user_ids()

const dictionaries = await load_saved_dictionaries()
Expand All @@ -36,12 +32,12 @@ async function migrate_the_rest() {
const fb_dictionary_infos = await get_info_by_dictionary_id()

let sql_query = 'BEGIN;' // Start a transaction
if (environment === 'dev') {
for (const { id, name } of dictionaries) {
const dictionary_sql = sql_file_string('dictionaries', { id, name, created_by: jacob_ld_user_id, updated_by: jacob_ld_user_id })
sql_query += `${dictionary_sql}\n`
}
}
// if (environment === 'dev') {
// for (const { id, name } of dictionaries) {
// const dictionary_sql = sql_file_string('dictionaries', { id, name, created_by: jacob_ld_user_id, updated_by: jacob_ld_user_id })
// sql_query += `${dictionary_sql}\n`
// }
// }

const sql = generate_inserts({
dictionary_ids: dictionaries.map(({ id }) => id),
Expand Down
16 changes: 2 additions & 14 deletions packages/scripts/migrate-to-supabase/notes.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
# Migrate Auth
- commit, check, test
- push sql to prod
- lock firebase
- run all data-migrations
- partners `dictionaries/${dictionary.id}/partners`
- invites `dictionaries/${dictionary.id}/invites`
- managers `dictionaries/${dictionary.id}/managers`
- contributors `dictionaries/${dictionary.id}/contributors`
- write_in_collaborators `dictionaries/${dictionary.id}/writeInCollaborators`
- about: `dictionaries/${dictionary.id}/info/about`
- grammar `dictionaries/${dictionary.id}/info/grammar`
- citation `dictionaries/${dictionary.id}/info/citation`
- push code live
## Clean Up
- entry history from pop-up entry modal
- test admin rls, alternative is auth.jwt() read https://supabase.com/docs/guides/database/postgres/row-level-security#authjwt to see if better
Expand All @@ -32,6 +18,8 @@
- remove unneeded urls from https://console.cloud.google.com/auth/clients/215143435444-fugm4gpav71r3l89n6i0iath4m436qnv.apps.googleusercontent.com?inv=1&invt=AboyXQ&project=talking-dictionaries-alpha
- move featured images to photos table and make a connection to the dictionary
- use line-clamp instead of truncateString in SelectedDict.svelte and also look at inline-children-elements purpose
- delete dev Firebase project and create new gcs dev bucket
- adjust user migration to set these fields to empty strings and not null to avoid db errors: `confirmation_token`, `recovery_token`, `email_change_token_new`, `email_change`

# Migrate Entries and Speakers from Firestore to Supabase

Expand Down
10 changes: 5 additions & 5 deletions packages/site/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
<Toasts />
{/await}

<!-- {#if $user} -->
{#await import('./Banner.svelte') then { default: Banner }}
<Banner />
{/await}
<!-- {/if} -->
<!-- {#if $user}
{#await import('./Banner.svelte') then { default: Banner }}
<Banner />
{/await}
{/if} -->

<div id="direction" dir={$page.data.t('page.direction')}>
<slot />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,8 @@ SELECT
dictionary_roles.role,
profiles_view.full_name,
profiles_view.avatar_url
FROM
dictionary_roles
JOIN
profiles_view ON dictionary_roles.user_id = profiles_view.id;
FROM dictionary_roles
JOIN profiles_view ON dictionary_roles.user_id = profiles_view.id;

CREATE TYPE status_enum AS ENUM ('queued', 'sent', 'claimed', 'cancelled');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ CREATE POLICY "Anyone can view dictionary info."
ON dictionary_info FOR SELECT
USING (true);

------------------------

CREATE TABLE dictionary_partners (
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
Expand Down
81 changes: 0 additions & 81 deletions supabase/migrations/20250205145300_users_with_dictionary_roles.sql
Original file line number Diff line number Diff line change
Expand Up @@ -42,84 +42,3 @@ BEGIN
GROUP BY auth.users.id, user_data.unsubscribed_from_emails, user_data.terms_agreement;
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;

-- CREATE OR REPLACE FUNCTION dictionaries_with_editors()
-- RETURNS TABLE (
-- id text,
-- name text,
-- alternate_names text[],
-- gloss_languages text[],
-- location text,
-- coordinates jsonb,
-- iso_639_3 text,
-- glottocode text,
-- public boolean,
-- print_access boolean,
-- metadata jsonb,
-- entry_count bigint,
-- orthographies jsonb[],
-- featured_image jsonb,
-- author_connection text,
-- community_permission public.certainty,
-- language_used_by_community boolean,
-- con_language_description text,
-- copyright text,
-- created_at timestamp with time zone,
-- created_by uuid,
-- updated_at timestamp with time zone,
-- updated_by uuid,
-- editors jsonb
-- ) AS $$
-- BEGIN
-- IF NOT is_admin() THEN
-- RETURN;
-- END IF;

-- RETURN QUERY
-- WITH editors_cte AS (
-- SELECT
-- dictionary_roles.dictionary_id,
-- jsonb_agg(
-- jsonb_build_object(
-- 'user_id', auth.users.id,
-- 'email', auth.users.email::text,
-- 'full_name', auth.users.raw_user_meta_data->>'full_name',
-- 'avatar_url', auth.users.raw_user_meta_data->>'avatar_url',
-- 'role', dictionary_roles.role,
-- 'created_at', dictionary_roles.created_at,
-- 'invited_by', dictionary_roles.invited_by
-- )
-- ) FILTER (WHERE dictionary_roles.dictionary_id IS NOT NULL) AS editors
-- FROM dictionary_roles
-- LEFT JOIN auth.users ON dictionary_roles.user_id = auth.users.id
-- GROUP BY dictionary_roles.dictionary_id
-- )
-- SELECT
-- dictionaries_view.id,
-- dictionaries_view.name,
-- dictionaries_view.alternate_names,
-- dictionaries_view.gloss_languages,
-- dictionaries_view.location,
-- dictionaries_view.coordinates,
-- dictionaries_view.iso_639_3,
-- dictionaries_view.glottocode,
-- dictionaries_view.public,
-- dictionaries_view.print_access,
-- dictionaries_view.metadata,
-- dictionaries_view.entry_count,
-- dictionaries_view.orthographies,
-- dictionaries_view.featured_image,
-- dictionaries_view.author_connection,
-- dictionaries_view.community_permission,
-- dictionaries_view.language_used_by_community,
-- dictionaries_view.con_language_description,
-- dictionaries_view.copyright,
-- dictionaries_view.created_at,
-- dictionaries_view.created_by,
-- dictionaries_view.updated_at,
-- dictionaries_view.updated_by,
-- COALESCE(editors_cte.editors, '[]'::jsonb) AS editors
-- FROM dictionaries_view
-- LEFT JOIN editors_cte ON dictionaries_view.id = editors_cte.dictionary_id;
-- END;
-- $$ LANGUAGE plpgsql SECURITY DEFINER;

0 comments on commit 9c18975

Please sign in to comment.