Skip to content

Commit

Permalink
Merge pull request #32 from line/beta
Browse files Browse the repository at this point in the history
release: 3.2334.7
  • Loading branch information
h4l-yup authored Aug 23, 2023
2 parents 2316dd9 + fee0370 commit 82d5c66
Show file tree
Hide file tree
Showing 304 changed files with 460 additions and 78,533 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/docker-dev-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Docker Dev Image CI

on:
push:
tags:
- '**-dev'

jobs:
api-build:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Docker meta
id: api-meta
uses: docker/metadata-action@v4
with:
images: line/abc-user-feedback-api
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push API
uses: docker/build-push-action@v4
with:
context: .
file: ./apps/api/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.api-meta.outputs.tags }}
labels: ${{ steps.api-meta.outputs.labels }}

web-build:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Docker meta
id: web-meta
uses: docker/metadata-action@v4
with:
images: line/abc-user-feedback-web
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Web
uses: docker/build-push-action@v4
with:
context: .
file: ./apps/web/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.web-meta.outputs.tags }}
labels: ${{ steps.web-meta.outputs.labels }}
74 changes: 0 additions & 74 deletions .github/workflows/docker-image.yml

This file was deleted.

75 changes: 75 additions & 0 deletions .github/workflows/docker-prod-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Docker Prod Image CI

on:
push:
tags:
- '*'
- '!**-beta'
- '!**-dev'

jobs:
api-build:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Docker meta
id: api-meta
uses: docker/metadata-action@v4
with:
images: line/abc-user-feedback-api
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push API
uses: docker/build-push-action@v4
with:
context: .
file: ./apps/api/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.api-meta.outputs.tags }}
labels: ${{ steps.api-meta.outputs.labels }}

web-build:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Docker meta
id: web-meta
uses: docker/metadata-action@v4
with:
images: line/abc-user-feedback-web
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Web
uses: docker/build-push-action@v4
with:
context: .
file: ./apps/web/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.web-meta.outputs.tags }}
labels: ${{ steps.web-meta.outputs.labels }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ yarn-error.log*


.vscode
volumes
volumes

dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class IssueNameUnique1692690482919 implements MigrationInterface {
name = 'IssueNameUnique1692690482919'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP INDEX \`IDX_b711d3eb6f21e35f5a0623dbe2\` ON \`issues\``);
await queryRunner.query(`CREATE UNIQUE INDEX \`issue-name-unique\` ON \`issues\` (\`name\`, \`project_id\`)`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP INDEX \`issue-name-unique\` ON \`issues\``);
await queryRunner.query(`CREATE UNIQUE INDEX \`IDX_b711d3eb6f21e35f5a0623dbe2\` ON \`issues\` (\`name\`)`);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class TypeOrmConfigService implements TypeOrmOptionsFactory {
logging: ['warn', 'error'],
migrationsRun: process.env.AUTO_MIGRATION === 'true',
namingStrategy: new SnakeNamingStrategy(),
timezone: process.env.TZ,
timezone: '+00:00',
};
}
}
5 changes: 5 additions & 0 deletions apps/api/src/domains/channel/field/field.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ export class FieldService {
analyzer: 'ngram_analyzer',
search_analyzer: 'ngram_analyzer',
}
: field.format === FieldFormatEnum.date
? {
type: FIELD_TYPES_TO_MAPPING_TYPES[field.format],
format: `yyyy-MM-dd HH:mm:ss||yyyy-MM-dd HH:mm:ssZ||yyyy-MM-dd HH:mm:ssZZZZZ||yyyy-MM-dd||epoch_millis||strict_date_optional_time`,
}
: { type: FIELD_TYPES_TO_MAPPING_TYPES[field.format] },
}),
{},
Expand Down
24 changes: 15 additions & 9 deletions apps/api/src/domains/feedback/feedback.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,14 @@ export class FeedbackService {
);

for (const fieldKey of Object.keys(query)) {
if (['ids', 'issueIds', 'searchText'].includes(fieldKey)) {
return;
if (['ids', 'issueIds'].includes(fieldKey)) {
if (!Array.isArray(query[fieldKey])) {
throw new BadRequestException(`${fieldKey} must be array`);
}
continue;
}
if ('searchText' === fieldKey) {
continue;
}
if (!fieldsByKey[fieldKey]) {
throw new BadRequestException(`invalid key in query: ${fieldKey}`);
Expand All @@ -79,11 +85,11 @@ export class FeedbackService {
case FieldFormatEnum.boolean:
if (typeof query[fieldKey] !== 'boolean')
throw new BadRequestException(`${fieldKey} must be boolean`);
return;
break;
case FieldFormatEnum.keyword:
if (typeof query[fieldKey] !== 'string')
throw new BadRequestException(`${fieldKey} must be string`);
return;
break;
case FieldFormatEnum.date:
if (
typeof query[fieldKey] !== 'object' ||
Expand All @@ -93,25 +99,25 @@ export class FeedbackService {
)
)
throw new BadRequestException(`${fieldKey} must be DateTimeRange`);
return;
break;
case FieldFormatEnum.multiSelect:
if (!Array.isArray(query[fieldKey]))
throw new BadRequestException(
`${fieldKey} must be array of string`,
);
return;
break;
case FieldFormatEnum.number:
if (typeof query[fieldKey] !== 'number')
throw new BadRequestException(`${fieldKey} must be number`);
return;
break;
case FieldFormatEnum.select:
if (typeof query[fieldKey] !== 'string')
throw new BadRequestException(`${fieldKey} must be string`);
return;
break;
case FieldFormatEnum.text:
if (typeof query[fieldKey] !== 'string')
throw new BadRequestException(`${fieldKey} must be string`);
return;
break;
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions apps/api/src/domains/migration/migration.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { Inject, Logger } from '@nestjs/common';
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Client } from '@opensearch-project/opensearch';
import dayjs from 'dayjs';
import { Repository } from 'typeorm';

import { OpensearchRepository } from '@/common/repositories';
Expand Down Expand Up @@ -63,8 +64,8 @@ export class MigrationService {
id: feedback.id,
...feedback.rawData,
...feedback.additionalData,
createdAt: feedback.createdAt,
updatedAt: feedback.updatedAt,
createdAt: dayjs(feedback.createdAt).format('YYYY-MM-DD HH:mm:ssZ'),
updatedAt: dayjs(feedback.updatedAt).format('YYYY-MM-DD HH:mm:ssZ'),
};
});
this.logger.log('documents.length: ' + documents.length);
Expand All @@ -76,12 +77,13 @@ export class MigrationService {
refresh: true,
body: chunk.flatMap((doc) => {
const _id = doc.id;
return [{ index: { _index: index, _id } }, doc];
return [{ index: { _index: 'channel_' + index, _id } }, doc];
}),
});

if (res.body.errors) {
this.logger.error('migration error', index);
this.logger.error(res.body);
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion apps/api/src/domains/project/issue/issue.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
ManyToMany,
ManyToOne,
Relation,
Unique,
} from 'typeorm';

import { CommonEntity } from '@/common/entities';
Expand All @@ -30,8 +31,9 @@ import { ProjectEntity } from '../project/project.entity';

@Entity('issues')
@Index(['project.id', 'createdAt'])
@Unique('issue-name-unique', ['name', 'project'])
export class IssueEntity extends CommonEntity {
@Column('varchar', { length: 255, unique: true })
@Column('varchar', { length: 255 })
name: string;

@Column('varchar', { nullable: true })
Expand Down
1 change: 0 additions & 1 deletion apps/api/src/domains/project/issue/issue.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { Like, Repository } from 'typeorm';
import { TimeRange } from '@/common/dtos';
import { createQueryBuilder, mockRepository } from '@/utils/test-utils';

// import { ProjectEntity } from '../project/project.entity';
import {
CreateIssueDto,
FindIssuesByProjectIdDto,
Expand Down
Loading

0 comments on commit 82d5c66

Please sign in to comment.