Skip to content

Commit

Permalink
Merge pull request #26 from Bricks666/develop
Browse files Browse the repository at this point in the history
v2.4.0
  • Loading branch information
Bricks666 authored Feb 14, 2024
2 parents 1437466 + 4f89507 commit 71368fc
Show file tree
Hide file tree
Showing 43 changed files with 617 additions and 487 deletions.
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ services:
ports:
- 5433:5432
restart: always
volumes:
- db-data:/var/lib/postgresql/data
# volumes:
# - db-data:/var/lib/postgresql/data
env_file:
- .env.production
environment:
Expand All @@ -37,5 +37,5 @@ services:
always
container_name: cache
volumes:
db-data:
# db-data:
redis-data:
186 changes: 3 additions & 183 deletions package-lock.json

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

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "server",
"version": "2.3.0",
"version": "2.4.0",
"description": "",
"main": "./dist/index.js",
"scripts": {
Expand Down Expand Up @@ -33,7 +33,6 @@
"class-validator": "^0.14.0",
"cookie-parser": "^1.4.6",
"express": "^4.18.2",
"googleapis": "^131.0.0",
"handlebars": "^4.7.7",
"nodemailer": "^6.9.1",
"redis": "^4.6.5",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- AlterTable
ALTER TABLE "User" ALTER COLUMN "email" SET DATA TYPE VARCHAR(64),
ALTER COLUMN "username" SET DATA TYPE VARCHAR(64);
6 changes: 3 additions & 3 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ datasource db {

model User {
id Int @id @default(autoincrement())
email String @unique() @db.VarChar(32)
username String @db.VarChar(32)
email String @unique() @db.VarChar(64)
username String @db.VarChar(64)
password String @db.VarChar(255)
photo String? @db.VarChar(255)
activated Boolean? @default(false)
Expand Down Expand Up @@ -61,7 +61,7 @@ enum RoomInvitationStatus {
model Room {
id Int @id @default(autoincrement())
ownerId Int
name String @db.VarChar(32)
name String @db.VarChar(64)
description String @db.VarChar(255)
createdAt DateTime? @default(now())
updatedAt DateTime? @updatedAt
Expand Down
43 changes: 6 additions & 37 deletions src/activities/repositories/activity/activity.repository.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,15 @@
import { Injectable } from '@nestjs/common';
import { Prisma } from '@prisma/client';
import { DatabaseService } from '@/database/database.service';
import { SECURITY_USER_SELECT } from '@/users/repositories';
import { ActivityDto } from '../../dto';
import {
CreateParams,
GetAllByRoomIdParams,
GetAllByUserIdParams,
GetTotalCountInRoomParams
} from './types';
import { prepareWhere } from './lib';

const select = {
id: true,
roomId: true,
room_user: {
select: {
user: {
select: SECURITY_USER_SELECT,
},
},
},
sphere: true,
action: true,
createdAt: true,
} satisfies Prisma.ActivitySelect;
import { convertActivityRecordToActivityDto, prepareWhere } from './lib';
import { select } from './config';

@Injectable()
export class ActivityRepository {
Expand Down Expand Up @@ -55,7 +40,7 @@ export class ActivityRepository {
},
});

return activities.map(ActivityRepository.map);
return activities.map(convertActivityRecordToActivityDto);
}

async getTotalCountInRoom(
Expand Down Expand Up @@ -83,17 +68,10 @@ export class ActivityRepository {
},
take: limit,
skip: offset,
include: {
sphere: {
select: {
id: true,
name: true,
},
},
},
select,
});

return activities.map(ActivityRepository.map);
return activities.map(convertActivityRecordToActivityDto);
}

async create(params: CreateParams): Promise<ActivityDto> {
Expand Down Expand Up @@ -132,15 +110,6 @@ export class ActivityRepository {
select,
});

return ActivityRepository.map(activity);
}

private static map(activity: any): ActivityDto {
const { room_user, ...rest } = activity;

return {
...rest,
activist: room_user.user,
};
return convertActivityRecordToActivityDto(activity);
}
}
Loading

0 comments on commit 71368fc

Please sign in to comment.