-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
55 changed files
with
983 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
api-repo/src/main/kotlin/com/few/api/repo/dao/article/query/SelectArticleContentQuery.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.few.api.repo.dao.article.query | ||
|
||
data class SelectArticleContentQuery( | ||
val articleId: Long, | ||
) |
12 changes: 12 additions & 0 deletions
12
api-repo/src/main/kotlin/com/few/api/repo/dao/article/record/ArticleContentRecord.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.few.api.repo.dao.article.record | ||
|
||
import java.net.URL | ||
|
||
data class ArticleContentRecord( | ||
val id: Long, | ||
val category: String, | ||
val articleTitle: String, | ||
val articleContent: String, | ||
val writerName: String, | ||
val writerLink: URL, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
api-repo/src/main/kotlin/com/few/api/repo/dao/member/query/SelectMemberEmailQuery.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.few.api.repo.dao.member.query | ||
|
||
data class SelectMemberEmailQuery( | ||
val memberId: Long, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
...src/main/kotlin/com/few/api/repo/dao/subscription/command/UpdateArticleProgressCommand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.few.api.repo.dao.subscription.command | ||
|
||
data class UpdateArticleProgressCommand( | ||
val memberId: Long, | ||
val workbookId: Long, | ||
) |
7 changes: 7 additions & 0 deletions
7
...main/kotlin/com/few/api/repo/dao/subscription/command/UpdateLastArticleProgressCommand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.few.api.repo.dao.subscription.command | ||
|
||
data class UpdateLastArticleProgressCommand( | ||
val memberId: Long, | ||
val workbookId: Long, | ||
val opinion: String = "receive.all", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...o/src/main/kotlin/com/few/api/repo/dao/workbook/query/SelectWorkBookLastArticleIdQuery.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.few.api.repo.dao.workbook.query | ||
|
||
data class SelectWorkBookLastArticleIdQuery( | ||
val workbookId: Long, | ||
) |
78 changes: 78 additions & 0 deletions
78
api-repo/src/test/kotlin/com/few/api/repo/explain/ExplainGenerator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package com.few.api.repo.explain | ||
|
||
import org.jooq.DSLContext | ||
import org.jooq.Query | ||
|
||
class ExplainGenerator { | ||
companion object { | ||
/** | ||
* Execute EXPLAIN and EXPLAIN ANALYZE FORMAT=TREE | ||
*/ | ||
fun execute(dslContext: DSLContext, query: Query): String { | ||
val sql = query.sql | ||
val values = query.bindValues | ||
mapSqlAndValues(sql, values).let { | ||
val explain = StringBuilder() | ||
explain.append("EXPLAIN $it\n") | ||
explain.append("\n") | ||
dslContext.fetch("EXPLAIN $it").let { | ||
explain.append(it) | ||
} | ||
explain.append("\n\n") | ||
explain.append("EXPLAIN ANALYZE FORMAT=TREE $it\n") | ||
explain.append("\n") | ||
dslContext.fetch("EXPLAIN ANALYZE FORMAT=TREE $it").let { | ||
it.forEach { record -> | ||
explain.append(record[0].toString()) | ||
} | ||
} | ||
return explain.toString() | ||
} | ||
} | ||
|
||
/** | ||
* Execute EXPLAIN | ||
*/ | ||
fun explain(dslContext: DSLContext, query: Query): String { | ||
val sql = query.sql | ||
val values = query.bindValues | ||
mapSqlAndValues(sql, values).let { | ||
val explain = StringBuilder() | ||
explain.append("EXPLAIN $it\n") | ||
explain.append("\n") | ||
dslContext.fetch("EXPLAIN $it").let { | ||
explain.append(it) | ||
} | ||
return explain.toString() | ||
} | ||
} | ||
|
||
/** | ||
* Execute EXPLAIN ANALYZE FORMAT=TREE | ||
*/ | ||
fun analyzeFormatTree(dslContext: DSLContext, query: Query): String { | ||
val sql = query.sql | ||
val values = query.bindValues | ||
mapSqlAndValues(sql, values).let { | ||
val explain = StringBuilder() | ||
explain.append("EXPLAIN ANALYZE FORMAT=TREE $it\n") | ||
explain.append("\n") | ||
dslContext.fetch("EXPLAIN ANALYZE FORMAT=TREE $it").let { | ||
it.forEach { record -> | ||
explain.append(record[0].toString()) | ||
} | ||
} | ||
return explain.toString() | ||
} | ||
} | ||
|
||
private fun mapSqlAndValues(sql: String, values: List<Any>) = | ||
values.foldIndexed(sql) { index, acc, value -> | ||
if (value is String) { | ||
acc.replaceFirst("?", "'$value'") | ||
} else { | ||
acc.replaceFirst("?", "$value") | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.