Skip to content

Commit

Permalink
Push Algo avec Robin Triage Objet enlevage text pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan7594 committed May 30, 2024
1 parent 3857566 commit 4a75144
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 59 deletions.
59 changes: 1 addition & 58 deletions server/controllers/mediatheque.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
Expand Down Expand Up @@ -84,68 +84,11 @@ 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');

Check failure on line 88 in server/controllers/mediatheque.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
console.log(activitiesWithMediaOnly);

Check failure on line 89 in server/controllers/mediatheque.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement

res.send(activitiesWithMediaOnly);
});

// mediathequeController.post({ path: '/count' }, async (req, res) => {
// try {
// const filters: Array<Filter[]> = 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<Filter[]> = 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 };
2 changes: 1 addition & 1 deletion src/components/admin/mediatheque/DownloadButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {

Check failure on line 78 in src/components/admin/mediatheque/DownloadButton.tsx

View workflow job for this annotation

GitHub Actions / typescript

Property 'medias' does not exist on type 'Activity<AnyData>'.
if (contentItem.type === 'image') {
const imageUrl = contentItem.value;
const imageExtension = getFileExtension(imageUrl);
Expand Down

0 comments on commit 4a75144

Please sign in to comment.