Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Initial exploration for ferretdb support #1139

Open
wants to merge 1 commit into
base: stage
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
version: "3"
services:
mongodb:
container_name: mongodb
image: mongo:5.0.8
restart: unless-stopped
volumes:
- ${DATA_PATH}/mongodb:/data:delegated
- ${DATA_PATH}/mongodb/db:/data/db:delegated
# mongodb:
# container_name: mongodb
# image: mongo:5.0.8
# restart: unless-stopped
# volumes:
# - ${DATA_PATH}/mongodb:/data:delegated
# - ${DATA_PATH}/mongodb/db:/data/db:delegated
# ports:
# - "${MONGODB_PORT:-27017}:27017"

ferretdb:
container_name: ferretdb
image: ghcr.io/ferretdb/ferretdb
restart: on-failure
ports:
- "${MONGODB_PORT:-27017}:27017"
- 27017:27017
environment:
- FERRETDB_HANDLER=sqlite
volumes:
- ${DATA_PATH}/ferretdb:/state:delegated

localstack:
container_name: aletheia-localstack
Expand All @@ -25,4 +36,4 @@ services:
volumes:
- "${TMPDIR:-/tmp}/localstack:/tmp/localstack"
- "./data/localstack:${DATA_DIR:-/data/localstack}"
- "/var/run/docker.sock:/var/run/docker.sock"
- "/var/run/docker.sock:/var/run/docker.sock"
32 changes: 0 additions & 32 deletions newrelic_agent.log

This file was deleted.

2 changes: 1 addition & 1 deletion server/auth/ory/ory.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default class OryService {
Authorization: `Bearer ${token}`,
},
});

// FIXME: log errors in the server when creating an user
return await result.json();
}

Expand Down
8 changes: 4 additions & 4 deletions server/badge/dto/update-badge.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ import {

export class UpdateBadgeDTO {
@IsString()
@IsNotEmpty()
@IsOptional()
@ApiProperty()
_id: string;

@IsString()
@IsNotEmpty()
@IsOptional()
@ApiProperty()
name: string;

@IsString()
@IsNotEmpty()
@IsOptional()
@ApiProperty()
description: string;

@IsObject()
@IsNotEmpty()
@IsOptional()
@ApiProperty()
image: any;

Expand Down
2 changes: 1 addition & 1 deletion server/home/home.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class HomeController {
const { personalities } = await this.personalityService.combinedListAll(
{
language: req.language,
order: "random",
// order: "random",
pageSize: 6,
fetchOnly: true,
}
Expand Down
13 changes: 12 additions & 1 deletion server/personality/personality.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,15 @@
withSuggestions = false
) {
let personalities;

console.log(
page,

Check failure

Code scanning / CodeQL

Use of externally-controlled format string High

Format string depends on a
user-provided value
.
pageSize,
order,
query,
filter,
language,
withSuggestions
);
if (order === "random") {
personalities = await this.PersonalityModel.aggregate([
{
Expand All @@ -87,11 +95,13 @@
.sort({ _id: order })
.lean();
} else {
console.log("caiu aqui nessa porra");
personalities = await this.PersonalityModel.find(query)
.skip(page * pageSize)
.limit(pageSize)
.sort({ _id: order })
.lean();
console.log(personalities, "personalities");
}

if (withSuggestions) {
Expand Down Expand Up @@ -406,6 +416,7 @@
this.count(queryInputs),
])
.then(([personalities, totalPersonalities]) => {
console.log(personalities, totalPersonalities);
const totalPages = Math.ceil(
totalPersonalities / parseInt(pageSize, 10)
);
Expand Down
9 changes: 6 additions & 3 deletions server/seed.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { NestFactory } from "@nestjs/core";

Check failure on line 1 in server/seed.ts

View workflow job for this annotation

GitHub Actions / build (18.14.0)

Cannot find name 'EmailService'. Did you mean 'emailService'?

Check failure on line 1 in server/seed.ts

View workflow job for this annotation

GitHub Actions / build (18.14.0)

Cannot find name 'disableSMTP'.
import { AppModule } from "./app.module";
import { NestExpressApplication } from "@nestjs/platform-express";
import { EmailService } from "./email/email.service";
import { ConfigService } from "@nestjs/config";
import { UsersService } from "./users/users.service";
import { UtilService } from "./util";
Expand All @@ -22,7 +21,6 @@
const userService = app.get(UsersService);
const utilService = app.get(UtilService);
const users = configService.get<any>("users");
const disableSMTP = configService.get<any>("disable_smtp");

const seedSingleUser = async (userData, password) => {
return userService
Expand All @@ -48,6 +46,8 @@
return null;
});
};

console.log(users, "seed users");
// Using await Promise.all to force loop to finish before continuing
await Promise.all(
users.map(async (userData) => {
Expand All @@ -57,7 +57,10 @@
);
return seedSingleUser(userData, password);
})
);
).catch((e) => {
options.logger.log("error", e);
options.logger.log("info", "Error while seeding users");
});

logger.log("Seed is finished");
await app.close();
Expand Down
Loading