diff --git a/server/controllers/mediatheque.ts b/server/controllers/mediatheque.ts index 5d1aa3c6c..ddd7aa855 100644 --- a/server/controllers/mediatheque.ts +++ b/server/controllers/mediatheque.ts @@ -22,7 +22,7 @@ const getMedias = async (result: any[], queryBuilder, offset, limit) => { const result = { id, subType, type, villageId, userId, medias: [] }; if (content.game) { content.game.map(({ inputs }) => - inputs.map((input) => { + inputs.map((input: { type: number; selectedValue: string }) => { if (input.type === 3 || input.type === 4) { result.medias.push({ type: input.type === 3 ? 'image' : 'video', value: input.selectedValue }); } @@ -84,10 +84,6 @@ mediathequeController.post({ path: '' }, async (req, res) => { }), ); }); - - // if (limit) { - // subQueryBuilder = subQueryBuilder.limit(parseInt(limit)); - // } const activitiesWithMediaOnly = await getMedias([], subQueryBuilder, offset ? parseInt(offset) : undefined, limit ? parseInt(limit) : undefined); console.log('activitiesWithMediaOnly'); console.log(activitiesWithMediaOnly); @@ -95,57 +91,4 @@ mediathequeController.post({ path: '' }, async (req, res) => { res.send(activitiesWithMediaOnly); }); -// mediathequeController.post({ path: '/count' }, async (req, res) => { -// try { -// const filters: Array = req?.body?.filters || []; - -// let subQueryBuilder = AppDataSource.getRepository(Activity).createQueryBuilder('activity').innerJoin('activity.user', 'user'); - -// filters.map((filter, index) => { -// subQueryBuilder = subQueryBuilder[index === 0 ? 'where' : 'orWhere']( -// new Brackets((qb) => { -// filter.map(({ table, column, values }, subQueryIndex) => { -// let condition = ''; -// values.map((_value, valueIndex) => { -// condition += valueIndex > 0 ? ' or ' : '('; -// condition += `${table}.${column} = ${values[valueIndex]}`; -// }); -// condition += ')'; -// qb[subQueryIndex === 0 ? 'where' : 'andWhere'](condition); -// }); -// }), -// ); -// }); -// const count = await subQueryBuilder.getMany(); -// res.status(200).json({ count }); -// } catch (error) { -// console.error('Error fetching count:', error); -// res.status(500).json({ error: 'Internal Server Error' }); -// } -// }); - -// mediathequeController.post({ path: '/all' }, async (req, res) => { -// const filters: Array = req?.body?.filters || []; - -// let subQueryBuilder = AppDataSource.getRepository(Activity).createQueryBuilder('activity').innerJoin('activity.user', 'user'); - -// filters.map((filter, index) => { -// subQueryBuilder = subQueryBuilder[index === 0 ? 'where' : 'orWhere']( -// new Brackets((qb) => { -// filter.map(({ table, column, values }, subQueryIndex) => { -// let condition = ''; -// values.map((_value, valueIndex) => { -// condition += valueIndex > 0 ? ' or ' : '('; -// condition += `${table}.${column} = ${values[valueIndex]}`; -// }); -// condition += ')'; -// qb[subQueryIndex === 0 ? 'where' : 'andWhere'](condition); -// }); -// }), -// ); -// }); -// const activities = await subQueryBuilder.getMany(); - -// }); - export { mediathequeController }; diff --git a/src/components/admin/mediatheque/DownloadButton.tsx b/src/components/admin/mediatheque/DownloadButton.tsx index ad3276f04..f6e4b40d3 100644 --- a/src/components/admin/mediatheque/DownloadButton.tsx +++ b/src/components/admin/mediatheque/DownloadButton.tsx @@ -75,7 +75,7 @@ export default function DownloadButton() { const activityLabel = getActivityLabel(item.type); const subThemeLabel = getSubThemeLabel(item.type, item.subType); - item.content.forEach((contentItem: { type: string; value: string }, contentIndex: number) => { + item.medias.forEach((contentItem: { type: string; value: string }, contentIndex: number) => { if (contentItem.type === 'image') { const imageUrl = contentItem.value; const imageExtension = getFileExtension(imageUrl);