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

Remove unused properties, methods, entites, ... #281

Merged
merged 3 commits into from
Feb 10, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class EvaluationStep(
* Also useful to give more information about failures
*/
@Column(length = 1048576)
@Lob()
@Lob
@Type(type = "org.hibernate.type.TextType")
var summary: String? = null

Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/de/code_freak/codefreak/entity/Feedback.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import javax.persistence.ManyToOne
@Entity
class Feedback(
@Column(length = 1048576)
@Lob()
@Lob
@Type(type = "org.hibernate.type.TextType")
var summary: String
) : BaseEntity() {
Expand All @@ -32,7 +32,7 @@ class Feedback(
* Limit is set to 1MiB
*/
@Column(length = 1048576)
@Lob()
@Lob
@Type(type = "org.hibernate.type.TextType")
var longDescription: String? = null

Expand Down
31 changes: 0 additions & 31 deletions src/main/kotlin/de/code_freak/codefreak/entity/Requirement.kt

This file was deleted.

11 changes: 0 additions & 11 deletions src/main/kotlin/de/code_freak/codefreak/entity/Task.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,6 @@ class Task(
*/
var weight: Int?
) : BaseEntity(), Comparable<Task> {
/**
* Evaluations that will be applied to this task
*/
@OneToMany(mappedBy = "task")
var requirements: MutableSet<Requirement> = mutableSetOf()

/**
* Same like position but one-based index
*/
val number get() = this.position.plus(1L)

@CreationTimestamp
var createdAt: Instant = Instant.now()

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ class AnswerService : BaseService() {
@Autowired
private lateinit var taskService: TaskService

fun getAnswerIdsForTaskIds(taskIds: Iterable<UUID>, userId: UUID) = answerRepository.findIdsForTaskIds(taskIds, userId).toMap()

fun findAnswer(taskId: UUID, userId: UUID): Answer = answerRepository.findByTaskIdAndSubmissionUserId(taskId, userId)
.orElseThrow { EntityNotFoundException("Answer not found.") }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package de.code_freak.codefreak.service

data class ExecResult(val output: String, val exitCode: Long) {
private constructor() : this("", 0)
}
data class ExecResult(val output: String, val exitCode: Long)
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ class GitImportService : BaseService() {
@Autowired
lateinit var answerService: AnswerService

fun getSupportedHosts() = configuration.gitImport.remotes.map { remote -> remote.host }

fun getRemote(host: String) = configuration.gitImport.remotes.find { remote -> remote.host == host }

fun importFiles(remoteUrlString: String, answer: Answer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ package de.code_freak.codefreak.service
import de.code_freak.codefreak.auth.Role
import de.code_freak.codefreak.entity.Assignment
import de.code_freak.codefreak.entity.Classroom
import de.code_freak.codefreak.entity.Requirement
import de.code_freak.codefreak.entity.User
import de.code_freak.codefreak.repository.AssignmentRepository
import de.code_freak.codefreak.repository.ClassroomRepository
import de.code_freak.codefreak.repository.RequirementRepository
import de.code_freak.codefreak.repository.UserRepository
import de.code_freak.codefreak.util.TarUtil
import org.slf4j.LoggerFactory
Expand All @@ -32,7 +30,6 @@ class SeedDatabaseService : ApplicationListener<ContextRefreshedEvent>, Ordered
@Autowired lateinit var userRepository: UserRepository
@Autowired lateinit var assignmentRepository: AssignmentRepository
@Autowired lateinit var classroomRepository: ClassroomRepository
@Autowired lateinit var requirementRepository: RequirementRepository
@Autowired lateinit var taskService: TaskService
@Autowired lateinit var assignmentService: AssignmentService

Expand Down Expand Up @@ -96,10 +93,6 @@ class SeedDatabaseService : ApplicationListener<ContextRefreshedEvent>, Ordered
taskService.createFromTar(it.toByteArray(), null, teacher, 0)
}

val eval1 = Requirement(task1, "exec", hashMapOf("CMD" to "gcc -o main && ./main"))
val eval2 = Requirement(task2, "exec", hashMapOf("CMD" to "javac Main.java && java Main"))
requirementRepository.saveAll(listOf(eval1, eval2))

ByteArrayOutputStream().use {
TarUtil.createTarFromDirectory(ClassPathResource("init/tasks").file, it)
assignmentService.createFromTar(it.toByteArray(), teacher, Instant.now().plusMillis(60*1000)).let { result ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ class EvaluationService : BaseService() {
evaluationQueue.insert(answer.id)
}

fun getLatestEvaluations(answerIds: Iterable<UUID>): Map<UUID, Optional<Evaluation>> {
return answerIds.map { it to getLatestEvaluation(it) }.toMap()
}

fun getLatestEvaluation(answerId: UUID) = evaluationRepository.findFirstByAnswerIdOrderByCreatedAtDesc(answerId)

fun isEvaluationPending(answerId: UUID) = isEvaluationInQueue(answerId) || evaluationQueue.isRunning(answerId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CodeclimateRunner : EvaluationRunner {
}

override fun run(answer: Answer, options: Map<String, Any>): List<Feedback> {
var codeclimateJson = containerService.runCodeclimate(answer)
val codeclimateJson = containerService.runCodeclimate(answer)
return this.parseCodeclimateJson(codeclimateJson).map { issue ->
Feedback(issue.description).apply {
group = "${issue.engine_name}/${issue.check_name}"
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/db/changelog-master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ databaseChangeLog:
- include:
file: changelogs/20200127104317-task-pool.yaml
relativeToChangelogFile: true
- include:
file: changelogs/20200207111659-remove-requirements.yaml
relativeToChangelogFile: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
databaseChangeLog:
- changeSet:
id: 1581070754125-2
author: hkasch (generated)
changes:
- dropForeignKeyConstraint:
baseTableName: requirement
constraintName: FKht56di1qi1nu7snq745g9ilxn
- changeSet:
id: 1581070754125-3
author: hkasch (generated)
changes:
- dropForeignKeyConstraint:
baseTableName: requirement_adapter_config
constraintName: FKoku0pk2jphfp8aenheaiifc3p
- changeSet:
id: 1581070754125-4
author: hkasch (generated)
changes:
- dropTable:
tableName: requirement
- changeSet:
id: 1581070754125-5
author: hkasch (generated)
changes:
- dropTable:
tableName: requirement_adapter_config