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

Database Improvements #301

Merged
merged 4 commits into from
May 5, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions drizzle.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const { TURSO_DATABASE_URL, TURSO_AUTH_TOKEN } = process.env;

export default {
schema: './src/db/schema.ts',
out: './src/db/migrations',
driver: 'turso',
dbCredentials: {
url: TURSO_DATABASE_URL,
Expand Down
149 changes: 74 additions & 75 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -131,86 +131,31 @@ const redirects = [
destination: '/resources/jonathan-chapman',
permanent: true,
},
{
source: '/resources/thoughtleader-20',
destination: '/resources/ron-wakkary',
permanent: true,
},
{
source: '/resources/thoughtleader-21',
destination: '/resources/hemant-taneja',
permanent: true,
},
{
source: '/resources/thoughtleader-22',
destination: '/resources/kevin-maney',
permanent: true,
},
{
source: '/resources/thoughtleader-23',
destination: '/resources/kenneth-chenault',
permanent: true,
},
{
source: '/resources/thoughtleader-24',
destination: '/resources/leyla-acaroglu',
permanent: true,
},
{
source: '/resources/thoughtleader-25',
destination: '/resources/liza-kindred',
permanent: true,
},
{
source: '/resources/thoughtleader-26',
destination: '/resources/jane-fulton-suri',
permanent: true,
},
{
source: '/resources/thoughtleader-27',
destination: '/resources/carey-jenkins',
permanent: true,
},
{
source: '/resources/thoughtleader-28',
destination: '/resources/tim-jackson',
permanent: true,
},
{
source: '/resources/thoughtleader-29',
destination: '/resources/joe-toscano',
permanent: true,
},
{
source: '/resources/thoughtleader-30',
destination: '/resources/david-wortmann',
permanent: true,
},
{
source: '/resources/thoughtleader-31',
destination: '/resources/anthony-dunne',
permanent: true,
},
{
source: '/resources/thoughtleader-32',
destination: '/resources/fiona-raby',
permanent: true,
},
{
source: '/resources/thoughtleader-33',
destination: '/resources/simon-mundy',
permanent: true,
},
{
source: '/resources/thoughtleader-34',
destination: '/resources/bruce-mau',
permanent: true,
},
{
source: '/resources/thoughtleader-35',
destination: '/resources/alita-joyce',
permanent: true,
},
{
source: '/resources/thoughtleader-36',
destination: '/resources/solitaire-townsend',
Expand Down Expand Up @@ -266,11 +211,6 @@ const redirects = [
destination: '/resources/brent-toderian',
permanent: true,
},
{
source: '/resources/thoughtleader-47',
destination: '/resources/sierra-robinson',
permanent: true,
},
{
source: '/resources/thoughtleader-48',
destination: '/resources/janine-benyus',
Expand Down Expand Up @@ -368,7 +308,7 @@ const redirects = [
{
source: '/resources/article-8',
destination:
'/resources/life-centered-design--wie-design-mit-der-trendwende-vom-profit-zum-purpose-die-welt-retten-will',
'/resources/life-centered-design-wie-design-mit-der-trendwende-vom-profit-zum-purpose-die-welt-retten-will',
permanent: true,
},
{
Expand Down Expand Up @@ -406,7 +346,7 @@ const redirects = [
{
source: '/resources/article-15',
destination:
'/resources/your-next-persona-will-be-non-human--tools-for-environment-centered-designers',
'/resources/your-next-persona-will-be-non-human-tools-for-environment-centered-designers',
permanent: true,
},
{
Expand Down Expand Up @@ -441,7 +381,67 @@ const redirects = [
},
{
source: '/resources/example-2',
destination: '/resources/rewe-green-farming--supermarkt-umgedacht',
destination: '/resources/rewe-green-farming-supermarkt-umgedacht',
permanent: true,
},
{
source: '/resources/thoughtleader-20',
destination: '/resources/ron-wakkary',
permanent: true,
},
{
source: '/resources/thoughtleader-22',
destination: '/resources/kevin-maney',
permanent: true,
},
{
source: '/resources/thoughtleader-23',
destination: '/resources/kenneth-chenault',
permanent: true,
},
{
source: '/resources/thoughtleader-25',
destination: '/resources/liza-kindred',
permanent: true,
},
{
source: '/resources/thoughtleader-27',
destination: '/resources/carey-jenkins',
permanent: true,
},
{
source: '/resources/thoughtleader-28',
destination: '/resources/tim-jackson',
permanent: true,
},
{
source: '/resources/thoughtleader-30',
destination: '/resources/david-wortmann',
permanent: true,
},
{
source: '/resources/thoughtleader-31',
destination: '/resources/anthony-dunne',
permanent: true,
},
{
source: '/resources/thoughtleader-32',
destination: '/resources/fiona-raby',
permanent: true,
},
{
source: '/resources/thoughtleader-33',
destination: '/resources/simon-mundy',
permanent: true,
},
{
source: '/resources/thoughtleader-35',
destination: '/resources/alita-joyce',
permanent: true,
},
{
source: '/resources/thoughtleader-47',
destination: '/resources/sierra-robinson',
permanent: true,
},
{
Expand Down Expand Up @@ -470,7 +470,7 @@ const redirects = [
{
source: '/resources/book-5',
destination:
'/resources/world-wide-waste-how-digital-is-killing-our-planet--and-what-we-can-do-about-it-',
'/resources/world-wide-waste-how-digital-is-killing-our-planet-and-what-we-can-do-about-it-',
permanent: true,
},
{
Expand Down Expand Up @@ -736,7 +736,7 @@ const redirects = [
},
{
source: '/resources/community-16',
destination: '/resources/ecological-design-collective--community',
destination: '/resources/ecological-design-collective-community',
permanent: true,
},
{
Expand Down Expand Up @@ -852,8 +852,7 @@ const redirects = [
},
{
source: '/resources/podcastEpisode-20',
destination:
'/resources/the-future-is-life-centered---jane-fulton-suri-ideo',
destination: '/resources/the-future-is-life-centered-jane-fulton-suri-ideo',
permanent: true,
},
{
Expand Down Expand Up @@ -927,7 +926,7 @@ const redirects = [
},
{
source: '/resources/video-5',
destination: '/resources/life-centered-design-by-bruce-mau--bodw-2021',
destination: '/resources/life-centered-design-by-bruce-mau-bodw-2021',
permanent: true,
},
{
Expand All @@ -943,7 +942,7 @@ const redirects = [
{
source: '/resources/video-8',
destination:
'/resources/beyond-sustainability-a-call-for-regeneration--sierra-robinson--tedxyouthseattle',
'/resources/beyond-sustainability-a-call-for-regeneration-sierra-robinson-tedxyouthseattle',
permanent: true,
},
{
Expand All @@ -955,13 +954,13 @@ const redirects = [
{
source: '/resources/video-10',
destination:
'/resources/biomimicry-definition--examples-explained-with-drawings',
'/resources/biomimicry-definition-examples-explained-with-drawings',
permanent: true,
},
{
source: '/resources/video-11',
destination:
'/resources/circular-economy-definition--examples--sustainability-environment',
'/resources/circular-economy-definition-examples-sustainability-environment',
permanent: true,
},
{
Expand Down Expand Up @@ -1013,7 +1012,7 @@ const redirects = [
{
source: '/resources/video-21',
destination:
'/resources/creating-a-bio-industrial-revolution--janine-benyus',
'/resources/creating-a-bio-industrial-revolution-janine-benyus',
permanent: true,
},
{
Expand Down Expand Up @@ -1510,7 +1509,7 @@ const redirects = [
},
{
source: '/resources/tool-43',
destination: '/resources/sux---the-sustainable-ux-design-toolkit',
destination: '/resources/sux-the-sustainable-ux-design-toolkit',
permanent: true,
},
{
Expand Down Expand Up @@ -1739,7 +1738,7 @@ const redirects = [
},
{
source: '/resources/directory-12',
destination: '/resources/sustainable--ethical-methods-library',
destination: '/resources/sustainable-ethical-methods-library',
permanent: true,
},
{
Expand Down Expand Up @@ -1845,7 +1844,7 @@ const redirects = [
},
{
source: '/resources/directory-14',
destination: '/resources/sux-network---resource-collection--event-calendar',
destination: '/resources/sux-network-resource-collection-event-calendar',
permanent: true,
},
{
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"db:migrate": "tsx ./src/db/migrate.ts",
"db:execute": "tsx ./src/db/execute.ts",
"db:reset": "rm ./local.db && pnpm db:push && pnpm db:seed",
"db:generate": "drizzle-kit generate:sqlite",
"ui:add": "pnpm dlx shadcn-ui@latest add",
"ui:diff": "pnpm dlx shadcn-ui diff",
"prisma:generate": "prisma generate",
Expand Down
8 changes: 3 additions & 5 deletions src/components/ResourceCard/ResourceCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,9 @@ export const ResourceCard = async ({ resource, details }: Props) => {
}`}
>
{/* Category */}
{resource.category && (
<CategoryButton categoryName={resource.category.name}>
{resource.category.name}
</CategoryButton>
)}
<CategoryButton categoryName={resource.category.name}>
{resource.category.name}
</CategoryButton>

{/* Link */}
<div className="flex max-w-full flex-wrap gap-2">
Expand Down
9 changes: 6 additions & 3 deletions src/data/resources/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,12 @@ export const selectResources = async (
}

resourcesQuery.where(() => {
const where: Array<SQL<unknown> | undefined> = [
inArray(resource.id, resourceIdsQuery),
];
const where: Array<SQL<unknown> | undefined> = [];

// Limit
if (limit) {
where.push(inArray(resource.id, resourceIdsQuery));
}

// Search
if (filter.search) {
Expand Down
6 changes: 3 additions & 3 deletions src/db/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ const main = async () => {

const resources = await db.query.resource.findMany({
columns: {
id: true,
slug: true,
oldSlug: true,
},
});

const redirects = resources.map(({ id, oldSlug }) => ({
const redirects = resources.map(({ slug, oldSlug }) => ({
source: `/resources/${oldSlug}`,
destination: `/resources/${id}`,
destination: `/resources/${slug}`,
permanent: true,
}));

Expand Down
Loading
Loading