Skip to content
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
167 changes: 120 additions & 47 deletions .script/gSheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,22 +122,48 @@ async function getSheetRows(sheets) {
async function processConfigData(configRow) {
try {
if (!configRow || configRow.length === 0) {
console.warn('Config sheet is empty');
return {};
console.warn('Config sheet is empty, using default values');
return {
periods: [],
activitiesType: [],
imageBaseUrl: '',
periodsMap: {},
activityMap: {},
};
}

const driveData = configRow.find((it) => it._rowNumber === 3)['_rawData'];
const periods = configRow
.find((it) => it._rowNumber === 2)
['_rawData'].slice(1)[0]
// Safe data extraction with fallbacks
const driveDataRow = configRow.find((it) => it._rowNumber === 3);
const periodsRow = configRow.find((it) => it._rowNumber === 2);
const activitiesTypeRow = configRow.find((it) => it._rowNumber === 4);

if (!driveDataRow || !periodsRow || !activitiesTypeRow) {
console.error('Missing required config rows');
throw new Error('Config sheet is missing required data rows');
}

const driveData = driveDataRow['_rawData'];
const periodsData = periodsRow['_rawData'].slice(1)[0];
const activitiesTypeData = activitiesTypeRow['_rawData'].slice(1)[0];

if (!periodsData || !activitiesTypeData) {
console.error('Missing periods or activities type data');
throw new Error(
'Config sheet is missing periods or activities type data',
);
}

const periods = periodsData
.split(',')
.map((it) => it.trim());
const activitiesType = configRow
.find((it) => it._rowNumber === 4)
['_rawData'].slice(1)[0]
.map((it) => it.trim())
.filter((it) => it.length > 0);

const activitiesType = activitiesTypeData
.split(',')
.map((it) => it.trim());
const imageBaseUrl = driveData[1].trim();
.map((it) => it.trim())
.filter((it) => it.length > 0);

const imageBaseUrl = driveData && driveData[1] ? driveData[1].trim() : '';

return {
periods,
Expand Down Expand Up @@ -184,26 +210,50 @@ async function saveJsonFiles(data) {
function processPeopleData(peoplesRow, config) {
const { imageBaseUrl, periodsMap } = config;

peoplesRow.forEach((it) => {
const row = it['_rawData'];

const thumbnailId = (row[12] ?? '').match(/\/d\/(.*?)\/view/)?.[1] ?? '';
const key = row[0] || Math.random().toString(36).substring(2, 15);
const period = row[4];

periodsMap[period].push({
id: key,
period,
isOrganizer: row[5] === 'TRUE',
thumbnail: thumbnailId ? `${imageBaseUrl}${thumbnailId}` : '',
name: row[3],
part: row[6],
introduce: row[7],
review: row[8],
github: row[9],
linkedin: row[10],
etc: row[11],
});
peoplesRow.forEach((it, index) => {
try {
const row = it['_rawData'];

if (!row || row.length === 0) {
console.warn(`Skipping empty row at index ${index}`);
return;
}

const thumbnailId = (row[12] ?? '').match(/\/d\/(.*?)\/view/)?.[1] ?? '';
const key = row[0] || Math.random().toString(36).substring(2, 15);
const period = row[4];

// Check if period exists in periodsMap, if not, skip this row or create it
if (!period) {
console.warn(`Row ${index + 1}: Missing period value, skipping row`);
return;
}

if (!periodsMap[period]) {
console.warn(
`Row ${index + 1}: Period "${period}" not found in config. Available periods: ${Object.keys(periodsMap).join(', ')}`,
);
// Create the period if it doesn't exist
periodsMap[period] = [];
}

periodsMap[period].push({
id: key,
period,
isOrganizer: row[5] === 'TRUE',
thumbnail: thumbnailId ? `${imageBaseUrl}${thumbnailId}` : '',
name: row[3],
part: row[6],
introduce: row[7],
review: row[8],
github: row[9],
linkedin: row[10],
etc: row[11],
});
} catch (error) {
console.error(`Error processing people data at row ${index + 1}:`, error);
console.error('Row data:', it['_rawData']);
}
});

return periodsMap;
Expand All @@ -213,21 +263,44 @@ function processPeopleData(peoplesRow, config) {
function processActivityData(activitiesRow, config) {
const { imageBaseUrl, activityMap } = config;

activitiesRow.forEach((it) => {
const row = it['_rawData'];
const type = row[1] || 'B';

activityMap[type].push({
id: row[0],
type,
thumbnail: row[2] ? `${imageBaseUrl}${row[2]}&sz=w1000` : '',
title: row[3] || '',
description: row[4] || '',
name: row[5] || '',
date: row[6] || '',
link: row[7] || '',
profile: row[8] ? `${imageBaseUrl}${row[8]}` : '',
});
activitiesRow.forEach((it, index) => {
try {
const row = it['_rawData'];

if (!row || row.length === 0) {
console.warn(`Skipping empty activity row at index ${index}`);
return;
}

const type = row[1] || 'B';

// Check if activity type exists in activityMap, if not, create it
if (!activityMap[type]) {
console.warn(
`Row ${index + 1}: Activity type "${type}" not found in config. Available types: ${Object.keys(activityMap).join(', ')}`,
);
// Create the activity type if it doesn't exist
activityMap[type] = [];
}

activityMap[type].push({
id: row[0],
type,
thumbnail: row[2] ? `${imageBaseUrl}${row[2]}&sz=w1000` : '',
title: row[3] || '',
description: row[4] || '',
name: row[5] || '',
date: row[6] || '',
link: row[7] || '',
profile: row[8] ? `${imageBaseUrl}${row[8]}` : '',
});
} catch (error) {
console.error(
`Error processing activity data at row ${index + 1}:`,
error,
);
console.error('Row data:', it['_rawData']);
}
});

return activityMap;
Expand Down
9 changes: 7 additions & 2 deletions src/app/people/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@ type SearchParams = {
function Page({ searchParams }: { searchParams?: SearchParams }) {
const people = getPeople();
const peopleData = getEntries(people);
const sortedPeopleGenerations = [...peopleData]

const filteredPeopleData = peopleData.filter(
([, peopleArray]) => peopleArray.length > 0,
);
const sortedPeopleGenerations = [...filteredPeopleData]
.sort((a, b) => sortDescending(a[0], b[0]))
.map(([generation]) => generation);

const selectedPeopleGeneration = searchParams?.generation || '3';
const selectedPeopleGeneration =
searchParams?.generation || sortedPeopleGenerations[0];
const currentPeople = people[selectedPeopleGeneration];

const sortedCurrentPeople = [...currentPeople].sort((a, b) => {
Expand Down
10 changes: 2 additions & 8 deletions src/components/organisms/people/UserCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
};

function UserCard({
period,

Check warning on line 27 in src/components/organisms/people/UserCard/index.tsx

View workflow job for this annotation

GitHub Actions / check lint

'period' is defined but never used. Allowed unused args must match /^_/u
img,
name,
links,
Expand All @@ -33,14 +33,8 @@
introduce = '',
review = '',
}: UserCardProps) {
const isContributor = period === 'contribute';

return (
<CardWrapper
type="CONTENT"
className="people-box"
minHeight={isContributor ? undefined : 270}
>
<CardWrapper type="CONTENT" className="people-box" minHeight={270}>
<section className={styles.userInfo}>
<Image
className={styles.profile}
Expand Down Expand Up @@ -74,7 +68,7 @@
</section>
</section>
<section className={styles.introduceWrapper}>{introduce}</section>
{!isContributor && (
{review && (
<section className={styles.reviewWrapper}>
<h3>활동후기</h3>
<p>{review}</p>
Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/People/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function People({
active={generation === selectedPeopleGeneration}
href={`/people?generation=${generation}`}
>
{generation === 'contribute' ? '기여자' : `${generation}기`}
{`${generation}기`}
</Button>
))}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/db/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface Activity {
video: ActivityVideo[];
}

export type PeopleGeneration = '1' | '2' | '3' | 'contribute';
export type PeopleGeneration = '1' | '2' | '3' | '4';

export type People = Record<PeopleGeneration, PeopleItem[]>;

Expand Down