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

. #40

Closed
wants to merge 6 commits into from
Closed

. #40

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
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# soongpt-backend

[![Dev - Tests](https://github.com/yourssu/soongpt-backend/actions/workflows/dev-ci.yml/badge.svg)](https://github.com/yourssu/soongpt-backend/actions/workflows/dev-ci.yml)
[![Dev - CI/CD without Tests](https://github.com/yourssu/soongpt-backend/actions/workflows/dev-cd.yml/badge.svg)](https://github.com/yourssu/soongpt-backend/actions/workflows/dev-cd.yml)
## Github Actions
[![Dev - Test](https://github.com/yourssu/soongpt-backend/actions/workflows/dev-pr.yml/badge.svg)](https://github.com/yourssu/soongpt-backend/actions/workflows/dev-pr.yml)
[![Dev - Build and Deploy to EC2](https://github.com/yourssu/soongpt-backend/actions/workflows/dev-push.yml/badge.svg)](https://github.com/yourssu/soongpt-backend/actions/workflows/dev-push.yml)

[![Prod - Tests](https://github.com/yourssu/soongpt-backend/actions/workflows/prod-ci.yml/badge.svg)](https://github.com/yourssu/soongpt-backend/actions/workflows/prod-ci.yml)
[![Prod - CI/CD with Tests](https://github.com/yourssu/soongpt-backend/actions/workflows/prod.yml/badge.svg)](https://github.com/yourssu/soongpt-backend/actions/workflows/prod.yml)
[![Prod - Test](https://github.com/yourssu/soongpt-backend/actions/workflows/main-pr.yml/badge.svg)](https://github.com/yourssu/soongpt-backend/actions/workflows/main-pr.yml)
[![Prod - Build and Deploy to EC2](https://github.com/yourssu/soongpt-backend/actions/workflows/main-push.yml/badge.svg)](https://github.com/yourssu/soongpt-backend/actions/workflows/main-push.yml)
23 changes: 23 additions & 0 deletions src/main/kotlin/com/yourssu/soongpt/common/config/CacheConfig.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.yourssu.soongpt.common.config

import org.springframework.cache.CacheManager
import org.springframework.cache.annotation.EnableCaching
import org.springframework.cache.concurrent.ConcurrentMapCache
import org.springframework.cache.support.SimpleCacheManager
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
@EnableCaching
class CacheConfig {
@Bean
fun cacheManager(): CacheManager {
val cacheManager = SimpleCacheManager()
cacheManager.setCaches(
listOf(
ConcurrentMapCache("courseCache"),
)
)
return cacheManager
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.yourssu.soongpt.domain.departmentGrade.implement.DepartmentGradeReade
import com.yourssu.soongpt.domain.target.implement.Target
import com.yourssu.soongpt.domain.target.implement.TargetReader
import com.yourssu.soongpt.domain.target.implement.TargetWriter
import org.springframework.cache.annotation.Cacheable
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional

Expand All @@ -29,6 +30,7 @@ class CourseService(
private val targetWriter: TargetWriter,
private val targetMapper: TargetMapper
) {
@Cacheable(value = ["courseCache"], key = "'majorRequired'.concat(#command.departmentName).concat(#command.grade)")
fun findByDepartmentNameInMajorRequired(command: FoundDepartmentCommand): List<CourseResponse> {
val department = departmentReader.getByName(command.departmentName)
val departmentGrade = departmentGradeReader.getByDepartmentIdAndGrade(department.id!!, command.grade)
Expand All @@ -43,6 +45,7 @@ class CourseService(
})
}

@Cacheable(value = ["courseCache"], key = "'MajorElective'.concat(#command.departmentName).concat(#command.grade)")
fun findByDepartmentNameInMajorElective(command: FoundDepartmentCommand): List<CourseResponse> {
val department = departmentReader.getByName(command.departmentName)
val courses = courseReader.findAllByDepartmentIdInMajorElective(department.id!!)
Expand All @@ -55,6 +58,7 @@ class CourseService(
})
}

@Cacheable(value = ["courseCache"], key = "'GeneralRequired'.concat(#command.departmentName).concat(#command.grade)")
fun findByDepartmentNameInGeneralRequired(command: FoundDepartmentCommand): List<CourseResponse> {
val department = departmentReader.getByName(command.departmentName)
val departmentGrade = departmentGradeReader.getByDepartmentIdAndGrade(department.id!!, command.grade)
Expand Down Expand Up @@ -152,4 +156,4 @@ class CourseService(
val target = targetReader.findAllByCourseId(courseId)
return CourseResponse.from(course, target, courseTimes)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.yourssu.soongpt.domain.timetable.business.dto

import com.yourssu.soongpt.domain.course.implement.Classification
import com.yourssu.soongpt.domain.course.implement.Course
import com.yourssu.soongpt.domain.courseTime.business.dto.CourseTimeResponse
import com.yourssu.soongpt.domain.courseTime.implement.CourseTime
Expand All @@ -8,7 +9,7 @@ data class TimetableCourseResponse(
val courseName: String,
val professorName: String?,
val classification: String,
val credit: Int,
val credit: Double,
val courseTime: List<CourseTimeResponse>,
) {
companion object {
Expand All @@ -17,9 +18,16 @@ data class TimetableCourseResponse(
courseName = course.courseName,
professorName = course.professorName,
classification = course.classification.name,
credit = course.credit,
credit = course.credit.toDouble() + addCreditIfChapel(course.classification),
courseTime = courseTimes.map { CourseTimeResponse.from(it) },
)
}

private fun addCreditIfChapel(classification: Classification): Double {
if (classification == Classification.CHAPEL) {
return 0.5
}
return 0.0
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ data class TimetableResponse(
val timetableId: Long,
val tag: String,
var score: Int?,
val totalCredit: Int,
val totalCredit: Double,
val courses: List<TimetableCourseResponse>,
) {
companion object {
Expand All @@ -20,4 +20,4 @@ data class TimetableResponse(
)
}
}
}
}
16 changes: 16 additions & 0 deletions src/main/resources/http/slack.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

@SLACK_WEBHOOK_URL = https://slack.com/api/chat.postMessage
@SLACK_TOKEN = xoxb
@SLACK_CHANNEL = channel-id

###
POST {{SLACK_WEBHOOK_URL}}
Authorization: Bearer {{SLACK_TOKEN}}
Content-Type: application/json

{
"channel": "{{SLACK_CHANNEL}}",
"text": "Hello, Slack!"
}

###
6 changes: 3 additions & 3 deletions src/main/resources/http/timetable.http
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@host = localhost:9000
@host = localhost:9001

###
POST {{host}}/api/timetables
Expand All @@ -21,7 +21,7 @@ Content-Type: application/json
],
"majorElectiveCredit": 9,
"generalElectiveCredit": 6,
"chapel": true
"isChapel": true
}
###

Expand All @@ -33,4 +33,4 @@ Content-Type: application/json
GET {{host}}/api/timetables/{{timeTableId}}
Content-Type: application/json

###
###