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

Feature: Last Minute Fixes #102

Merged
merged 2 commits into from
Oct 15, 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
2 changes: 1 addition & 1 deletion src/components/TeamDisplayRight.astro
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const { teamName, team, teamDescription } = Astro.props;
<h2 class="coms-title"><b>{teamName}</b></h2>
<p class="main-description-box-coms">
{teamDescription}
<button class="learn-more-coms">LEARN MORE</button>

</p>
</div>
</div>
Expand Down
5 changes: 0 additions & 5 deletions src/components/Unused.astro
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ import "../styles/global.css";
consectetur adipiscing elit. Nullam eget eleifend nibh. Maecenas ut
turpis ante.
</p>
<button class="learn-more-lead">LEARN MORE</button>
</div>
<div class="right1">
<ul class="people-c1">
Expand Down Expand Up @@ -261,7 +260,6 @@ import "../styles/global.css";
consectetur adipiscing elit. Nullam eget eleifend nibh. Maecenas ut
turpis ante.
</p>
<button class="learn-more-coms">LEARN MORE</button>
</div>
</div>

Expand All @@ -274,9 +272,6 @@ import "../styles/global.css";
Praesent rutrum in dui ut feugiat. Lorem ipsum dolor sit amet,
consectetur adipiscing elit. Nullam eget eleifend nibh. Maecenas ut
turpis ante.
<button class="learn-more-proj"
><a href="/projects/team1">LEARN MORE</a></button
>
</p>
</div>
<div class="right1">
Expand Down
2 changes: 1 addition & 1 deletion src/components/projectspage/ProjectsImageCarousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default function ProjectsImageCarousel({ projects }: CarouselProps) {
return (
<>
<div style={{ width: "100%", height: "100%", position: "relative", padding: "10px"}}>
<div className="index-event-img" style={{ width: "100%", height: "100%", display: "flex", overflow: "hidden" }}>
<div className="index-event-img" style={{ width: "100%", display: "flex", overflow: "hidden" }}>
{events.map((event, index) => (
<img key={index} src={event.src} alt={event.alt} className="index-event-image-container" style={{ translate: `${-100 * imgIndex}%`, opacity: 0.7, aspectRatio: "14/6" }}/>
))}
Expand Down
34 changes: 30 additions & 4 deletions src/scripts/updateProjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Client } from "@notionhq/client";
import type { projectRow } from '../types/projectRow.ts';
import axios from 'axios';
import sharp from "sharp";
import { supabase } from '../lib/supabaseClient';
import { supabase } from '../lib/supabaseClient';
import { supabaseUrl } from '../lib/supabaseClient';
import { prisma } from "../lib/prisma.ts";
import type { APIRoute } from 'astro';
Expand Down Expand Up @@ -75,15 +75,41 @@ export async function updateProjects(controller: ReadableStreamDefaultController
try {
sendLog(controller, "Starting to retrieve projects from Notion...");

// Step 1: Get all project IDs from Notion
const query = await notion.databases.query({
database_id: NOTION_PROJECTS_ID,
sorts: [{ property: 'Date', direction: 'descending' }]
});

const projectsRows = query.results as projectRow[];

console.log(projectsRows[0].properties)
// Get Notion project IDs
const notionProjectIds = projectsRows.map(row => row.id);

// Step 2: Get all projects from the Prisma database
const prismaProjects = await prisma.project.findMany({
select: { id: true, cover: true }, // Select only the fields needed for deletion
});
const prismaProjectIds = prismaProjects.map(project => project.id);

// Step 3: Identify projects to delete (those in Prisma but not in Notion)
const projectsToDelete = prismaProjects.filter(project => !notionProjectIds.includes(project.id));

// Step 4: Delete projects from Prisma and Supabase
for (const project of projectsToDelete) {
// Delete the project image from Supabase if it exists
if (project.cover) {
await deleteImageFromSupabase(project.cover); // Assuming the cover stores the file path
}

// Delete the project from Prisma
await prisma.project.delete({
where: { id: project.id },
});

sendLog(controller, `Deleted project ${project.id} from Prisma and its image from Supabase.`);
}

// Process the remaining projects (already in your existing logic)
const projectPromises = projectsRows.map(async (row) => {
const title = row.properties.Name.title[0] ? row.properties.Name.title[0].plain_text : "";
const dateStr = row.properties.Date.date ? row.properties.Date.date.start : "";
Expand Down Expand Up @@ -170,4 +196,4 @@ export async function updateProjects(controller: ReadableStreamDefaultController
console.error("Error retrieving or processing projects:", error);
sendLog(controller, `Error retrieving or processing projects: ${(error as Error).message}`);
}
}
}
2 changes: 1 addition & 1 deletion src/styles/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
}

.index-event-img {
height: 350px;
height: auto;
width: 100%;
object-fit: cover;
display: block;
Expand Down
Loading