Skip to content

Commit

Permalink
feat(moderation): only list email of user with the same family name (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasduteil authored Jun 26, 2024
1 parent ed30786 commit 84c9e15
Show file tree
Hide file tree
Showing 12 changed files with 271 additions and 155 deletions.
10 changes: 2 additions & 8 deletions packages/hono-slotify/src/__snapshots__/indext.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
// Bun Snapshot v1, https://goo.gl/fbAQLP

exports[`Basic render 1`] = `"<div>beforecomponent<div>beforeslot IN_SLOT afterslot; ownChildren: BEFORE_SLOTAFTER_SLOT</div>aftercomponent</div>"`;

exports[`Renderer undefined childs 1`] = `"<div>beforecomponent<div>beforeslot undefined afterslot; ownChildren: BEFORE_SLOTAFTER_SLOT</div>aftercomponent</div>"`;

exports[`render basic slot 1`] = `"<div>beforecomponent<div>beforeslot IN_SLOT afterslot; ownChildren: BEFORE_SLOTAFTER_SLOT</div>aftercomponent</div>"`;

exports[`eender undefined childs 1`] = `"<div>beforecomponent<div>beforeslot undefined afterslot; ownChildren: BEFORE_SLOTAFTER_SLOT</div>aftercomponent</div>"`;

exports[`render undefined childs 1`] = `"<div>beforecomponent<div>beforeslot undefined afterslot; ownChildren: BEFORE_SLOTAFTER_SLOT</div>aftercomponent</div>"`;

exports[`render default content if slot is not used 1`] = `"<main>beforecomponent<pre>beforeslotDEFAULT_SLOT_CONTENTafterslot; ownChildren: Slot not used</pre>aftercomponent</main>"`;

exports[`pass default children to function 1`] = `"<main><pre><div>foo=DEFAULT_SLOT_CONTENT</div></pre></main>"`;

exports[`pass parameters 1`] = `"<main><pre><div>foo=bar</div></pre></main>"`;

exports[`pass default children to function 1`] = `"<main><pre><div>foo=DEFAULT_SLOT_CONTENT</div></pre></main>"`;
2 changes: 1 addition & 1 deletion packages/hono-slotify/src/indext.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test("render basic slot", () => {
).toMatchSnapshot();
});

test("eender undefined childs", () => {
test("render undefined childs", () => {
const TestSlot = createSlot();
const Component: FC<PropsWithChildren> = ({ children }) => {
return (
Expand Down
13 changes: 4 additions & 9 deletions packages/~/infra/moncomptepro/database/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
//

import type { NodePgDatabase } from "drizzle-orm/node-postgres";
import type { PgliteDatabase } from "drizzle-orm/pglite";
import type { PgDatabase, QueryResultHKT } from "drizzle-orm/pg-core";
import Pg from "pg";
import * as schema from "./drizzle/relations";

//

export { drizzle, type NodePgClient } from "drizzle-orm/node-postgres";
export { drizzle } from "drizzle-orm/node-postgres";
export { schema };
export type MonComptePro_NodePgDatabase = NodePgDatabase<typeof schema>;
export type MonComptePro_PgliteDatabase = PgliteDatabase<typeof schema>;
export type MonComptePro_PgDatabase =
| MonComptePro_NodePgDatabase
| MonComptePro_PgliteDatabase;

export type MonComptePro_PgDatabase = PgDatabase<QueryResultHKT, typeof schema>;
export const Pool = Pg.Pool;
export type { NodePgDatabase };

//

Expand Down
38 changes: 18 additions & 20 deletions packages/~/infra/moncomptepro/database/src/seed/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,45 @@

import consola from "consola";
import { sql } from "drizzle-orm";
import type { MonComptePro_NodePgDatabase } from "../index";
import type { MonComptePro_PgDatabase } from "../index";
import { schema } from "../index";

//

export async function delete_database(db: MonComptePro_NodePgDatabase) {
export async function delete_database(db: MonComptePro_PgDatabase) {
try {
const users_organizations = await db.delete(schema.users_organizations);
const users_organizations = await db
.delete(schema.users_organizations)
.returning();
consola.verbose(
`🚮 ${users_organizations.command} ${users_organizations.rowCount} users_organizations`,
`🚮 DELETE ${users_organizations.length} users_organizations`,
);

const users_oidc_clients = await db.delete(schema.users_oidc_clients);
const users_oidc_clients = await db
.delete(schema.users_oidc_clients)
.returning();
await db.execute(
sql`ALTER SEQUENCE users_oidc_clients_id_seq RESTART WITH 1`,
);
consola.verbose(
`🚮 ${users_oidc_clients.command} ${users_oidc_clients.rowCount} users_oidc_clients`,
`🚮 DELETE ${users_oidc_clients.length} users_oidc_clients`,
);

const oidc_clients = await db.delete(schema.oidc_clients);
const oidc_clients = await db.delete(schema.oidc_clients).returning();
await db.execute(sql`ALTER SEQUENCE oidc_clients_id_seq RESTART WITH 1`);
consola.verbose(
`🚮 ${oidc_clients.command} ${oidc_clients.rowCount} oidc_clients`,
);
consola.verbose(`🚮 DELETE ${oidc_clients.length} oidc_clients`);

const users = await db.delete(schema.users);
const users = await db.delete(schema.users).returning();
await db.execute(sql`ALTER SEQUENCE users_id_seq RESTART WITH 1`);
consola.verbose(`🚮 ${users.command} ${users.rowCount} users`);
consola.verbose(`🚮 DELETE ${users.length} users`);

const organizations = await db.delete(schema.organizations);
const organizations = await db.delete(schema.organizations).returning();
await db.execute(sql`ALTER SEQUENCE organizations_id_seq RESTART WITH 1`);
consola.verbose(
`🚮 ${organizations.command} ${organizations.rowCount} organizations`,
);
consola.verbose(`🚮 DELETE ${organizations.length} organizations`);

const moderations = await db.delete(schema.moderations);
const moderations = await db.delete(schema.moderations).returning();
await db.execute(sql`ALTER SEQUENCE moderations_id_seq RESTART WITH 1`);
consola.verbose(
`🚮 ${moderations.command} ${moderations.rowCount} moderations`,
);
consola.verbose(`🚮 DELETE ${moderations.length} moderations`);
} catch (err) {
console.error("Something went wrong...");
console.error(err);
Expand Down
72 changes: 36 additions & 36 deletions packages/~/infra/moncomptepro/database/src/seed/insert.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//

import consola from "consola";
import type { MonComptePro_NodePgDatabase } from "../index";
import type { MonComptePro_PgDatabase } from "../index";
import { schema } from "../index";
import type { MCP_Moderation } from "../moncomptepro";

//

export async function insert_database(db: MonComptePro_NodePgDatabase) {
export async function insert_database(db: MonComptePro_PgDatabase) {
try {
const raphael = await insert_raphael(db);
consola.verbose(
Expand Down Expand Up @@ -55,98 +55,98 @@ export async function insert_database(db: MonComptePro_NodePgDatabase) {

//

const raphael_dinum = await insert_users_organizations(db, {
await insert_users_organizations(db, {
organization_id: dinum.id,
user_id: raphael.id,
});
consola.verbose(
`🌱 ${raphael_dinum.command} ${raphael_dinum.rowCount} ${raphael.given_name} join ${dinum.cached_libelle}`,
`🌱 INSERT ${raphael.given_name} join ${dinum.cached_libelle} `,
);

const marie_bon_join_bosch_rexroth = await insert_users_organizations(db, {
await insert_users_organizations(db, {
organization_id: bosch_rexroth.id,
user_id: marie_bon.id,
});
consola.verbose(
`🌱 ${marie_bon_join_bosch_rexroth.command} ${marie_bon_join_bosch_rexroth.rowCount} ${marie_bon.given_name} join ${bosch_rexroth.cached_libelle}`,
`🌱 INSERT ${marie_bon.given_name} join ${bosch_rexroth.cached_libelle}`,
);

//

const jeanbon_dinum = await insert_moderation(db, {
await insert_moderation(db, {
created_at: new Date("2011-11-11 11:11:11").toISOString(),
organization_id: dinum.id,
type: "organization_join_block" as MCP_Moderation["type"],
user_id: jean_bon.id,
});
consola.verbose(
`🌱 ${jeanbon_dinum.command} ${jeanbon_dinum.rowCount} ${jean_bon.given_name} wants to join ${dinum.cached_libelle}`,
`🌱 INSERT ${jean_bon.given_name} wants to join ${dinum.cached_libelle}`,
);

const jeanbon_abracadabra = await insert_moderation(db, {
await insert_moderation(db, {
created_at: new Date("2011-11-11 00:02:59").toISOString(),
organization_id: abracadabra.id,
type: "organization_join_block" as MCP_Moderation["type"],
user_id: jean_bon.id,
});
consola.verbose(
`🌱 ${jeanbon_abracadabra.command} ${jeanbon_abracadabra.rowCount} ${jean_bon.given_name} wants to join ${abracadabra.cached_libelle}`,
`🌱 INSERT ${jean_bon.given_name} wants to join ${abracadabra.cached_libelle}`,
);

const pierrebon_aldp = await insert_moderation(db, {
await insert_moderation(db, {
organization_id: aldp.id,
type: "big_organization_join" as MCP_Moderation["type"],
user_id: pierre_bon.id,
});
consola.verbose(
`🌱 ${pierrebon_aldp.command} ${pierrebon_aldp.rowCount} ${pierre_bon.family_name} wants to join ${aldp.cached_libelle}`,
`🌱 INSERT ${pierre_bon.family_name} wants to join ${aldp.cached_libelle}`,
);

const richard_bon_dengi = await insert_moderation(db, {
await insert_moderation(db, {
organization_id: dengi.id,
type: "organization_join_block" as MCP_Moderation["type"],
user_id: richard_bon.id,
moderated_at: new Date("2023-06-22 14:34:34").toISOString(),
});
consola.verbose(
`🌱 ${richard_bon_dengi.command} ${richard_bon_dengi.rowCount} ${richard_bon.given_name} wants to join ${dengi.cached_nom_complet}`,
`🌱 INSERT ${richard_bon.given_name} wants to join ${dengi.cached_nom_complet}`,
);

const richard_bon_dengi_bis = await insert_moderation(db, {
await insert_moderation(db, {
organization_id: dengi.id,
type: "organization_join_block" as MCP_Moderation["type"],
user_id: richard_bon.id,
});
consola.verbose(
`🌱 ${richard_bon_dengi_bis.command} ${richard_bon_dengi_bis.rowCount} ${richard_bon.given_name} wants to join ${dengi.cached_nom_complet} again...`,
`🌱 INSERT ${richard_bon.given_name} wants to join ${dengi.cached_nom_complet} again...`,
);

const marie_bon_bosch_france = await insert_moderation(db, {
await insert_moderation(db, {
organization_id: bosch_france.id,
type: "non_verified_domain" as MCP_Moderation["type"],
user_id: marie_bon.id,
});
consola.verbose(
`🌱 ${marie_bon_bosch_france.command} ${marie_bon_bosch_france.rowCount} ${marie_bon.given_name} wants to join ${bosch_france.cached_nom_complet} again...`,
`🌱 INSERT ${marie_bon.given_name} wants to join ${bosch_france.cached_nom_complet} again...`,
);

const marie_bon_bosch_rexroth = await insert_moderation(db, {
await insert_moderation(db, {
organization_id: bosch_rexroth.id,
type: "non_verified_domain" as MCP_Moderation["type"],
user_id: marie_bon.id,
moderated_at: new Date("2023-06-22 14:34:34").toISOString(),
});
consola.verbose(
`🌱 ${marie_bon_bosch_rexroth.command} ${marie_bon_bosch_rexroth.rowCount} ${marie_bon.given_name} wants to join ${bosch_rexroth.cached_nom_complet} again...`,
`🌱 INSERT ${marie_bon.given_name} wants to join ${bosch_rexroth.cached_nom_complet} again...`,
);
const raphael_alpha_dinum = await insert_moderation(db, {
await insert_moderation(db, {
organization_id: dinum.id,
type: "non_verified_domain" as MCP_Moderation["type"],
user_id: raphael_alpha.id,
moderated_at: new Date("2023-06-22 14:34:34").toISOString(),
});
consola.verbose(
`🌱 ${raphael_alpha_dinum.command} ${raphael_alpha_dinum.rowCount} ${raphael_alpha.given_name} wants to join ${dinum.cached_nom_complet} again...`,
`🌱 INSERT ${raphael_alpha.given_name} wants to join ${dinum.cached_nom_complet} again...`,
);
} catch (err) {
console.error("Something went wrong...");
Expand All @@ -157,22 +157,22 @@ export async function insert_database(db: MonComptePro_NodePgDatabase) {
//

function insert_moderation(
db: MonComptePro_NodePgDatabase,
db: MonComptePro_PgDatabase,
insert_moderation: typeof schema.moderations.$inferInsert,
) {
return db.insert(schema.moderations).values(insert_moderation);
}

function insert_users_organizations(
db: MonComptePro_NodePgDatabase,
db: MonComptePro_PgDatabase,
insert_users_organizations: typeof schema.users_organizations.$inferInsert,
) {
return db
.insert(schema.users_organizations)
.values(insert_users_organizations);
}

async function insert_jeanbon(db: MonComptePro_NodePgDatabase) {
async function insert_jeanbon(db: MonComptePro_PgDatabase) {
const insert = await db
.insert(schema.users)
.values({
Expand All @@ -190,7 +190,7 @@ async function insert_jeanbon(db: MonComptePro_NodePgDatabase) {
return insert.at(0)!;
}

async function insert_pierrebon(db: MonComptePro_NodePgDatabase) {
async function insert_pierrebon(db: MonComptePro_PgDatabase) {
const insert = await db
.insert(schema.users)
.values({
Expand All @@ -209,7 +209,7 @@ async function insert_pierrebon(db: MonComptePro_NodePgDatabase) {
return insert.at(0)!;
}

async function insert_richardbon(db: MonComptePro_NodePgDatabase) {
async function insert_richardbon(db: MonComptePro_PgDatabase) {
const insert = await db
.insert(schema.users)
.values({
Expand All @@ -228,7 +228,7 @@ async function insert_richardbon(db: MonComptePro_NodePgDatabase) {
return insert.at(0)!;
}

async function insert_mariebon(db: MonComptePro_NodePgDatabase) {
async function insert_mariebon(db: MonComptePro_PgDatabase) {
const insert = await db
.insert(schema.users)
.values({
Expand All @@ -247,7 +247,7 @@ async function insert_mariebon(db: MonComptePro_NodePgDatabase) {
return insert.at(0)!;
}

async function insert_raphael(db: MonComptePro_NodePgDatabase) {
async function insert_raphael(db: MonComptePro_PgDatabase) {
const insert = await db
.insert(schema.users)
.values({
Expand All @@ -265,7 +265,7 @@ async function insert_raphael(db: MonComptePro_NodePgDatabase) {
return insert.at(0)!;
}

async function insert_raphael_alpha(db: MonComptePro_NodePgDatabase) {
async function insert_raphael_alpha(db: MonComptePro_PgDatabase) {
const insert = await db
.insert(schema.users)
.values({
Expand All @@ -285,7 +285,7 @@ async function insert_raphael_alpha(db: MonComptePro_NodePgDatabase) {

//

async function insert_abracadabra(db: MonComptePro_NodePgDatabase) {
async function insert_abracadabra(db: MonComptePro_PgDatabase) {
const insert = await db
.insert(schema.organizations)
.values({
Expand Down Expand Up @@ -313,7 +313,7 @@ async function insert_abracadabra(db: MonComptePro_NodePgDatabase) {
return insert.at(0)!;
}

async function insert_aldp(db: MonComptePro_NodePgDatabase) {
async function insert_aldp(db: MonComptePro_PgDatabase) {
const insert = await db
.insert(schema.organizations)
.values({
Expand All @@ -338,7 +338,7 @@ async function insert_aldp(db: MonComptePro_NodePgDatabase) {
return insert.at(0)!;
}

async function insert_dinum(db: MonComptePro_NodePgDatabase) {
async function insert_dinum(db: MonComptePro_PgDatabase) {
const insert = await db
.insert(schema.organizations)
.values({
Expand All @@ -362,7 +362,7 @@ async function insert_dinum(db: MonComptePro_NodePgDatabase) {
return insert.at(0)!;
}

async function insert_dengi(db: MonComptePro_NodePgDatabase) {
async function insert_dengi(db: MonComptePro_PgDatabase) {
const insert = await db
.insert(schema.organizations)
.values({
Expand All @@ -386,7 +386,7 @@ async function insert_dengi(db: MonComptePro_NodePgDatabase) {
return insert.at(0)!;
}

async function insert_bosch_france(db: MonComptePro_NodePgDatabase) {
async function insert_bosch_france(db: MonComptePro_PgDatabase) {
const insert = await db
.insert(schema.organizations)
.values({
Expand All @@ -412,7 +412,7 @@ async function insert_bosch_france(db: MonComptePro_NodePgDatabase) {
return insert.at(0)!;
}

async function insert_bosch_rexroth(db: MonComptePro_NodePgDatabase) {
async function insert_bosch_rexroth(db: MonComptePro_PgDatabase) {
const insert = await db
.insert(schema.organizations)
.values({
Expand Down
Loading

0 comments on commit 84c9e15

Please sign in to comment.