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

feat(be): add client get submission order option #1692

Open
wants to merge 51 commits into
base: main
Choose a base branch
from

Conversation

mnseok
Copy link
Contributor

@mnseok mnseok commented May 13, 2024

Description

제출 목록 불러오는 순서를 정할 수 있도록 option을 부여했습니다.

option 종류:
id-asc, id-desc
memory-asc, memory-desc
cpuTime-asc, cpuTime-desc
date-asc, date-desc

만약 제출 결과가 Accepted가 아닌 경우에는 maxCpuTime과 maxMemoryUsage를 0으로 설정합니다.

Additional context

현재는 submission result에 의존하기 때문에 DB에서 데이터를 불러온 후 최댓값을 찾고 이를 통해 정렬합니다.
DBMS상에서 정렬 된 개선 방법이 있다면 알려주세요.

  • raw query를 사용하면 가능한데 ORM 쓰는 의미가 없어질 것 같아서 배제했습니다

Before submitting the PR, please make sure you do the following

Copy link

vercel bot commented May 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
codedang ❌ Failed (Inspect) Jul 4, 2024 10:06am

@mnseok mnseok changed the title 1316 add client get submission order option feat(be): add client get submission order option May 13, 2024
@mnseok mnseok requested a review from jspark2000 May 13, 2024 12:36
Comment on lines +488 to +498
codeSize: true,
submissionResult: {
where: {
result: ResultStatus.Accepted
},
select: {
result: true,
cpuTime: true,
memoryUsage: true
}
}
Copy link
Member

@jspark2000 jspark2000 May 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

submissionResult 테이블에 대한 쿼리로 변경해보는 것은 어떨까요?

const submissionResults = await this.prisma.submissionResult.groupBy({
  take,
  skip: 10 /**페이지에 따라 변경 */,
  where: {
    result: ResultStatus.Accepted
  },
  by: ['submissionId'],
  _sum: {
    cpuTime: true,
    memoryUsage: true
  },
  orderBy: {
    /** 정렬 조건에따라 변경 */
    _sum: {
      cpuTime: 'asc'
    }
  }
})

const submissions = await this.prisma.submission.findMany({
  where: {
    id: {
      in: submissionResults.map((item) => item.submissionId)
    }
  },
  select: {
    /** 불러올 컬럼 설정 */
  }
})

/** TODO: submissionResult에 submissionId가 같으면 합치기 */

Copy link

dayongkr and others added 17 commits July 4, 2024 10:02
* feat(ci): run ci depending on code change

* fix: use valid if statement with expression

* feat: add condition to typecheck and test
* feat(fe): add vitest for frontend unit testing

* chore: change workspace filter name

* chore: rollback Test job
* fix(be): add argon2 hash options

* chore(be): constantization argon2 hash option

---------

Co-authored-by: Jaehyeon Kim <[email protected]>
Co-authored-by: Jaehyeon Kim <[email protected]>
* chore(be): seperate total field from get-problems apis

* chore(be): resolve path conflict problem

* docs(be): add get-problem-count api docs

* chore(be): remove finished field from returned object of get-finished-contests

* Revert "chore(be): remove finished field from returned object of get-finished-contests"

This reverts commit 4ae342a.

* Revert "docs(be): add get-problem-count api docs"

This reverts commit cb29f05.

* Revert "chore(be): resolve path conflict problem"

This reverts commit 37b12dc.

* Revert "chore(be): seperate total field from get-problems apis"

This reverts commit da674f8.

* chore(be): replace field name(problem module)

* chore(be): replace field name(group module)

* chore(be): replace field name(notice module)

* chore(be): replace field name(submission module)

* chore(be): replace field name(workbook module)

* chore(be): replace field name(contest module)

* fix(be): add where condition

* fix(be): fix lint warning

* refactor(be): remove unused condition

* fix(be): unpack config condition

* test(be): add notice-total

* fix(be): match options for count total

---------

Co-authored-by: Jiyun Park <[email protected]>
chore: add resize to editor attributes
fix(infra): fix terraform version error
* refactor(fe): move graphql queries to graphql folder

* refactor(fe): edit query name and order
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
dayongkr and others added 28 commits July 4, 2024 10:03
* feat(fe): persist language and code datas

* fix(fe): change a code store
* feat(be): implement image upload to S3

* docs(be): add upload image api docs

* chore(be): modify image bucket baseurl

* docs(be): add assert

* chore(be): add alt property to return type of image-upload api

* chore(infra): rename testcase to storage

* feat(infra): add env for media bucket

* chore(be): add sample image and modify return object
- 샘플 이미지 추가
- src, alt 반환하던 것에서 src만 반환하는 것으로 변경

* Optimised images with calibre/image-actions

* chore(be): add s3-media-provider to test code

* chore(be): use relative path for sample image

* chore(be): replace client with media-client

* feat(be): add delete-image function

* refactor: combine bucket setup scripts

* fix(be): modify modify image size calculating logic
- 5MB 초과 파일이 들어왔을 때도 계속해서 파일 사이즈를 계산하는 문제 수정
- 5MB 초과 시 파일 사이즈 계산 중지, 예외 던지도록 구현

* chore(be): modify filename to use uuid only

* chore(be): remove duplicated import lines

* chore(be): remove file extension

* feat(be): add delete-image and improve image upload, delete logic

* docs(be): add delete-image api docs

* chore(be): parallelize deleting image logic

* chore(be): parallelize image-delete api

---------

Co-authored-by: k1g99 <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Jiyun Park <[email protected]>
…1714)

* refactor(infra): move codedang-tf-backend module to project

* refactor(infra): delete unused terraform project

* chore(infra): prepare refactoring codedang project

* chore(infra): change tfstate file name

* feat(infra): add terraform format in lefthook

* refactor(infra): add projects network and storage

* chore(infra): change dir name from projects to production
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* fix(deps): update dependency @headlessui/react to v2

* chore(fe): change default transition

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jimin Ha <[email protected]>
* chore(deps): update all non-major dependencies

* fix: format

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jaemin Choi <[email protected]>
fix: add tag name into aws eip
- GroupMemberGuard에서 group이 OPEN_SPACE_ID이면 로그인 상태여도 user role이 주입되지 않는 문제 해결
* fix(deps): update all non-major dependencies

* fix(fe): apply prisma breaking change

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jimin Ha <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* feat: add katex rendering function

* feat: change katex render function with useRef

* chore: render with useEffect

* feat(fe): save

* fix(fe): delete annotation

---------

Co-authored-by: jiho <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* feat: implement indent extension

* chore: replace textarea with texteditor
* fix(fe): handle undefined for fixed notices

* chore(fe): delete spaces
* chore(fe): prevent signup modal reset

* chore(fe): prevent modal closing when clicking outside
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.