Skip to content

Commit

Permalink
Merge pull request #4193 from alkem-io/develop
Browse files Browse the repository at this point in the history
Release: Fixes
  • Loading branch information
valentinyanakiev authored Jul 1, 2024
2 parents 3c4965b + 1029e63 commit a3e03a6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "alkemio-server",
"version": "0.82.7",
"version": "0.82.8",
"description": "Alkemio server, responsible for managing the shared Alkemio platform",
"author": "Alkemio Foundation",
"private": false,
Expand Down
38 changes: 29 additions & 9 deletions src/platform/activity/activity.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,39 @@ export class ActivityService {
limit,
} = options ?? {};

const defaultCondition = `activity.visibility = ${visibility} AND activity.collaborationId IN (${collaborationIDs
.map(c => `'${c}'`)
.join(',')})`;
const typesCondition =
types && types.length > 0
? `activity.type IN (${types.map(t => `'${t}'`).join(',')})`
const queryParameters: unknown[] = [];

const visibilityCondition = 'activity.visibility = ?';

queryParameters.push(visibility);

const collaborationIdsCondition =
collaborationIDs && collaborationIDs.length > 0
? 'activity.collaborationId IN (?)'
: undefined;

if (collaborationIdsCondition) {
queryParameters.push(collaborationIDs);
}

const typesCondition =
types && types.length > 0 ? 'activity.type IN (?)' : undefined;

if (typesCondition) {
queryParameters.push(types);
}

const triggeredByCondition = userID
? `activity.triggeredBy = '${userID}'`
? 'activity.triggeredBy = ?'
: undefined;

if (triggeredByCondition) {
queryParameters.push(userID);
}

const whereConditions = [
defaultCondition,
visibilityCondition,
collaborationIdsCondition,
typesCondition,
triggeredByCondition,
]
Expand All @@ -189,7 +208,8 @@ export class ActivityService {
group by activity.resourceId, activity.triggeredBy, activity.type
order by latest ${orderBy}
${limit ? `LIMIT ${limit}` : ''};
`
`,
queryParameters
);

const activityIDs = groupedActivities.map(a => a.latest);
Expand Down

0 comments on commit a3e03a6

Please sign in to comment.