Skip to content

Commit

Permalink
Merge branch 'develop' into feature/repository
Browse files Browse the repository at this point in the history
  • Loading branch information
ybkang1108 authored Jan 14, 2025
2 parents 1854046 + b2bf9f8 commit f057aca
Show file tree
Hide file tree
Showing 23 changed files with 124 additions and 294 deletions.
50 changes: 35 additions & 15 deletions .github/workflows/random_reviewer/reviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const member= {
cmj7271: "740776211231277066",
ybkang1108: "1038826581558296636",
yeeunli: "1082157260249251870",
JungJaehoon0430: "1007395745223151726"
JaehoonJung0430: "1007395745223151726"
}

function selectRandomReviewer() {
Expand Down Expand Up @@ -38,9 +38,34 @@ function createMsg(reviewer, title) {

async function main() {
const githubClient = github.getOctokit(process.env.REVIEW_TOKEN);
const reviewer = selectRandomReviewer();
let reviewer = "";

const { owner, repo } = github.context.repo;
const pr_info = {
owner: owner,
repo: repo,
pull_number: github.context.payload.pull_request.number
}

const requested_reviewers = await githubClient.rest.pulls.listRequestedReviewers(pr_info)

if(requested_reviewers.data.users.length === 0) {
githubClient.rest.pulls.requestReviewers(
{
...pr_info,
reviewers: [reviewer]
}
)
.then((res) => console.log("reviewer assign success: ", res))
.catch((err) => {
console.log("reviewer assign failed:", err);
process.exit(1);
});
reviewer = selectRandomReviewer();
} else {
console.log("already assigned reviewer exist.")
reviewer = requested_reviewers.data.users[0].login;
}

const pr = await githubClient.rest.pulls.get(
{
Expand All @@ -50,20 +75,15 @@ async function main() {
}
)

githubClient.rest.pulls.requestReviewers(
{
owner: github.context.repo.owner,
repo: github.context.repo.repo,
pull_number: github.context.payload.pull_request.number,
reviewers: [reviewer]
}
)
.then((res) => console.log("reviewer assign success: ", res))
.catch((err) => console.log("reviewer assign failed:", err));

sendDiscordMsg(reviewer, pr.data.title)
.then(() => console.log("message send success"))
.catch(() => console.log("message send failed"));
.catch(() => {
console.log("message send failed");
process.exit(1);
});
}

main().then(() => console.log("success")).catch(() => console.log("failed"));
main().then(() => console.log("success")).catch(() => {
console.log("failed")
process.exit(1);
});
16 changes: 16 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,19 @@ spotless {
endWithNewline()
}
}

tasks.register("updateGitHooks", Copy) {
from "./scripts/pre-commit"
into ".git/hooks"
onlyIf {
System.getenv("NO_GIT_HOOKS") == "true"
}
}
tasks.register("executableGitHooks", Exec) {
commandLine "chmod", "ug+x", ".git/hooks/pre-commit"
dependsOn(updateGitHooks)
onlyIf {
System.getenv("NO_GIT_HOOKS") == "true"
}
}
compileJava.dependsOn(executableGitHooks)
2 changes: 2 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ services:
env_file:
- ./env/server.env
- ./env/db.env
environment:
- NO_GIT_HOOKS="true"
platform: linux/arm64
build:
context: .
Expand Down
16 changes: 16 additions & 0 deletions scripts/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

# 변경된 파일들 이름만 추출하여 저장
stagedFiles=$(git diff --staged --name-only)

# SpotlessApply 실행
echo "Running spotlessApply. Formatting code..."

./gradlew spotlessApply

# 변경사항이 발생한 파일들 다시 git add
for file in $stagedFiles; do
if test -f "$file"; then
git add "$file"
fi
done
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ public interface AnswerRepository extends JpaRepository<Answer, Long> {
*/
@Query(value = "select a from Answer a " +
"where a.member.id = :memberId")
List<Answer> findByMemberId(@Param("memberId") Long memberId);
List<Answer> findByMemberId(@Param("memberId") Long memberId)
}

This file was deleted.

17 changes: 0 additions & 17 deletions src/main/java/com/gdgoc/study_group/day/dto/DayDTO.java

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,43 @@
package com.gdgoc.study_group.member.repository;
package com.gdgoc.study_group.member.dao;

import com.gdgoc.study_group.member.domain.Member;
import com.gdgoc.study_group.study.domain.Study;
import com.gdgoc.study_group.studyMember.domain.StudyMemberStatus;
import java.util.List;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

@Repository
public interface MemberRepository extends JpaRepository<Member, Long> {
/**
* 해당 멤버가 해당 상태를 가진 스터디 목록들을 반환합니다.
*
* @param memberId 검색할 대상이 되는 멤버의 PK
* @param memberStatus 검색할 대상이 되는 멤버가 스터디에서 가지길 기대하는 상태
* @return 해당 멤버가 포함되고, 해당 상태를 상태로 가지는 스터디들을 반환합니다.
*/
@Query(
"SELECT sm.study FROM StudyMember sm WHERE"
+ " sm.member.id = :id AND"
+ " sm.studyMemberStatus = :memberStatus")
List<Study> findByMemberIdAndStatus(
@Param("id") Long memberId, @Param("memberStatus") StudyMemberStatus memberStatus);

Member findByGithub(String github);
/**
* 해당 멤버의 스터디에서의 상태를 조회합니다.
*
* @param memberId 검색할 멤버의 id
* @param studyId 검색할 스터디의 id
* @return 해당 스터디에서 멤버의 상태(Optional)
*/
@Query(
"SELECT sm.studyMemberStatus FROM StudyMember sm WHERE sm.member.id = :memberId AND"
+ " sm.study.id = :studyId")
Optional<StudyMemberStatus> findMemberStatus(
@Param("memberId") Long memberId, @Param("studyId") Long studyId);

Member findByGithub(String github);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.gdgoc.study_group.round.repository;
package com.gdgoc.study_group.round.dao;

import com.gdgoc.study_group.round.domain.Round;
import org.springframework.data.jpa.repository.JpaRepository;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.gdgoc.study_group.roundMember.repository;
package com.gdgoc.study_group.roundMember.dao;

import com.gdgoc.study_group.roundMember.domain.RoundMember;
import org.springframework.data.jpa.repository.JpaRepository;
Expand Down
48 changes: 0 additions & 48 deletions src/main/java/com/gdgoc/study_group/study/api/StudyController.java

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
package com.gdgoc.study_group.study.repository;
package com.gdgoc.study_group.study.dao;

import com.gdgoc.study_group.study.domain.Status;
import com.gdgoc.study_group.study.domain.Study;
import com.gdgoc.study_group.study.domain.StudyStatus;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface StudyRepository extends JpaRepository<Study, Long> {

// 특정 Status인 스터디 목록 조회
List<Study> findByStatus(Status status);

// 모집 중인 스터디 목록 조회(status != FINISHED)
List<Study> findByStatusNot(Status status);
// 특정 Status인 스터디 목록 조회
List<Study> findByStatus(StudyStatus studyStatus);

// 모집 중인 스터디 목록 조회(status != FINISHED)
List<Study> findByStatusNot(StudyStatus studyStatus);
}
Loading

0 comments on commit f057aca

Please sign in to comment.