Skip to content

Commit

Permalink
Merge branch 'master' into log-routes
Browse files Browse the repository at this point in the history
  • Loading branch information
demshy committed Sep 7, 2024
2 parents 0b8c59b + 7b392e3 commit f1a85c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
4 changes: 1 addition & 3 deletions src/activities/services/activities.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ export class ActivitiesService {
params: FindActivitiesInput = {},
currentUser: User = null,
): Promise<StatsActivities[]> {

const builder = this.activitiesRepository
.createQueryBuilder('ac')
.select('EXTRACT(YEAR FROM ac.date)', 'year')
Expand Down Expand Up @@ -247,7 +246,6 @@ export class ActivitiesService {
} as StatsActivities;
});
return myStats;

}

async find(params: FindActivitiesInput = {}): Promise<Activity[]> {
Expand Down Expand Up @@ -326,7 +324,7 @@ export class ActivitiesService {
ActivityRoute,
'ar',
'ar.activity_id = a.id AND (ar."publish" IN (:...publish))',
{ publish: ['log', 'public'] },
{ publish: ['public'] },
);

// Allow/disallow based on publishStatus of contained activity routes
Expand Down
13 changes: 6 additions & 7 deletions test/e2e/activity.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ describe('Activity', () => {
expect(activitiesIds).not.toContain(mockData.activities.nonCragActivity.id);
});

it('should get only public (or log) activity routes and only activities containing at least one public (or log) activity route when fetching as a guest', async () => {
it('should get only public activity routes and only activities containing at least one public activity route when fetching as a guest', async () => {
const response = await request(app.getHttpServer())
.post('/graphql')
.send({
Expand Down Expand Up @@ -304,14 +304,13 @@ describe('Activity', () => {
const numOfNonPublicActivityRoutes =
response.body.data.activities.items.filter(
(a) =>
a.routes.filter((ar) => !['log', 'public'].includes(ar.publish))
.length > 0,
a.routes.filter((ar) => !['public'].includes(ar.publish)).length > 0,
).length;
expect(numOfNonPublicActivityRoutes).toEqual(0);

const numOfActivitiesWithNoPublicActivityRoutes =
response.body.data.activities.items.filter(
(a) => !a.routes.some((ar) => ['log', 'public'].includes(ar.publish)),
(a) => !a.routes.some((ar) => ['public'].includes(ar.publish)),
).length;
expect(numOfActivitiesWithNoPublicActivityRoutes).toEqual(0);

Expand All @@ -320,7 +319,7 @@ describe('Activity', () => {
const returnedActivitiesIds = response.body.data.activities.items.map(
(a) => a.id,
);
expect(returnedActivitiesIds).toContain(
expect(returnedActivitiesIds).not.toContain(
mockData.activities.activityWithLogRoutes.id,
);
expect(returnedActivitiesIds).toContain(
Expand All @@ -340,15 +339,15 @@ describe('Activity', () => {
mockData.activities.activityWithPublicRoutes.activityRoutes
.publicActivityRoute.id,
);
expect(returnedActivityRoutesIds).toContain(
expect(returnedActivityRoutesIds).not.toContain(
mockData.activities.activityWithLogRoutes.activityRoutes.logActivityRoute
.id,
);
expect(returnedActivityRoutesIds).toContain(
mockData.activities.activityWithMixedRoutes.activityRoutes
.publicActivityRoute.id,
);
expect(returnedActivityRoutesIds).toContain(
expect(returnedActivityRoutesIds).not.toContain(
mockData.activities.activityWithMixedRoutes.activityRoutes
.logActivityRoute.id,
);
Expand Down

0 comments on commit f1a85c9

Please sign in to comment.