Skip to content

Commit

Permalink
Merge pull request #73 from RnDAO/update-guid-schema-validator
Browse files Browse the repository at this point in the history
[FEAUTRE]: update guild scheam validator
  • Loading branch information
cyri113 authored Jun 1, 2023
2 parents 1c9e359 + 62a056a commit 5221325
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 35 deletions.
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@ docker run -e RUN_LOCAL=true -e TYPESCRIPT_DEFAULT_STYLE=prettier -e VALIDATE_DO
```

Note: We have disabled HADOLINT for now as we are getting an error: `qemu: uncaught target signal 11 (Segmentation fault) - core dumped`.
=======

[![Maintainability](https://api.codeclimate.com/v1/badges/52d516c2ad7c262adb37/maintainability)](https://codeclimate.com/github/RnDAO/tc-dbComm/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/52d516c2ad7c262adb37/test_coverage)](https://codeclimate.com/github/RnDAO/tc-dbComm/test_coverage)


## Schema for rawinfo

### Tests

The CI Pipeline uses the `test` target from the Dockerfile to run the tests. You can run it locally with the following command:
Expand All @@ -30,7 +27,9 @@ docker compose -f docker-compose.test.yml up --exit-code-from app --build

Note: This will create a /coverage folder where you can review the coverage details.

## Schema for rawinfo
## Schema

### rawinfo

```ts
rawinfo {
Expand All @@ -50,7 +49,7 @@ rawinfo {
}
```

### Schema for user
### user

```ts
User {
Expand All @@ -72,7 +71,7 @@ User {
}
```

### Schema for heatmap
### heatmap

```ts
HeatMap {
Expand All @@ -93,7 +92,7 @@ HeatMap {
}
```

### Schema for guildMembers
### guildMembers

```ts
GuildMember {
Expand All @@ -108,7 +107,7 @@ GuildMember {

```

### Schema for memberactivities
### memberactivities

```ts
memberactivities {
Expand All @@ -132,7 +131,7 @@ memberactivities {
}
```

### Schema for channels
### channels

```ts
Channels {
Expand All @@ -142,7 +141,7 @@ Channels {
}
```

### Schema for token
### token

```ts
Token {
Expand All @@ -154,7 +153,7 @@ Token {
}
```

### Schema for guild
### guild

```ts
Guild {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/unit/models/guild.model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('Guild model', () => {
isInProgress: false,
icon: null,
window: [7, 1],
action: [1, 1, 1, 4, 3, 5, 5, 4, 3, 3, 2],
action: [1, 1, 1, 4, 3, 5, 5, 4, 3, 3, 2, 2, 1],
};
});

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@togethercrew.dev/db",
"version": "2.3.1",
"version": "2.3.2",
"description": "All interactions with DB",
"main": "./dist/index.js",
"scripts": {
Expand Down
36 changes: 18 additions & 18 deletions src/interfaces/RawInfo.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@ import { type Model } from 'mongoose';
import { type Snowflake } from 'discord.js';

export interface IRawInfo {
type: number,
author: Snowflake,
content: string,
createdDate: Date,
user_mentions: Array<Snowflake>,
role_mentions: Array<Snowflake>,
reactions: Array<Snowflake>,
replied_user: Snowflake | null | undefined,
messageId: Snowflake,
channelId: Snowflake,
channelName: string | null,
threadId: Snowflake | null,
threadName: string | null,
type: number;
author: Snowflake;
content: string;
createdDate: Date;
user_mentions: Snowflake[];
role_mentions: Snowflake[];
reactions: Snowflake[];
replied_user: Snowflake | null | undefined;
messageId: Snowflake;
channelId: Snowflake;
channelName: string | null;
threadId: Snowflake | null;
threadName: string | null;
}

export interface IRawInfoUpdateBody {
channelId?: Snowflake,
channelName?: string | null,
threadId?: Snowflake | null,
threadName?: string | null,
content?: string,
channelId?: Snowflake;
channelName?: string | null;
threadId?: Snowflake | null;
threadName?: string | null;
content?: string;
}

export interface RawInfoModel extends Model<IRawInfo> {
Expand Down
4 changes: 2 additions & 2 deletions src/models/schemas/Guild.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ const guildSchema = new Schema<IGuild, GuildModel>({
},
action: {
type: Array<number>,
default: [1, 1, 1, 4, 3, 5, 5, 4, 3, 3, 2],
default: [1, 1, 1, 4, 3, 5, 5, 4, 3, 3, 2, 2, 1],
validate: {
validator: function (arr: Array<number>) {
return arr.length === 11;
return arr.length === 13;
},
message: 'Action must be an array with exactly 11 numbers',
},
Expand Down
2 changes: 1 addition & 1 deletion src/models/schemas/RawInfo.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const rawInfoSchema = new Schema<IRawInfo>({
type: String,
},
channelName: {
type: String
type: String,
},

threadId: {
Expand Down

0 comments on commit 5221325

Please sign in to comment.