Skip to content

Commit 4c73559

Browse files
committed
nevermind
This reverts commit edbd132.
1 parent edbd132 commit 4c73559

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

src/main/kotlin/io/codemc/api/database/database.kt

+2-5
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,13 @@ fun removeAllUsers() = transaction(database) {
143143
/**
144144
* Adds a request to the database.
145145
* @param messageId The unique ID of the request according to Discord
146-
* @param threadId The unique ID of the thread according to Discord
147146
* @param userId The unique ID of the Discord user
148147
* @param githubName The GitHub username of the user
149148
* @param repoName The name of the repository
150149
* @return The result of the `INSERT` statement
151150
*/
152151
fun createRequest(
153152
messageId: Long,
154-
threadId: Long,
155153
userId: Long,
156154
githubName: String,
157155
repoName: String
@@ -160,7 +158,6 @@ fun createRequest(
160158

161159
return@transaction Requests.insert { row ->
162160
row[Requests.messageId] = messageId
163-
row[Requests.threadId] = threadId
164161
row[Requests.userId] = userId
165162
row[Requests.githubName] = githubName
166163
row[Requests.repoName] = repoName
@@ -178,7 +175,7 @@ fun getRequest(
178175
if (!Requests.exists()) return@transaction null
179176

180177
return@transaction Requests.selectAll().where { Requests.messageId eq messageId }
181-
.map { row -> Request(row[Requests.messageId], row[Requests.threadId], row[Requests.userId], row[Requests.githubName], row[Requests.repoName]) }
178+
.map { row -> Request(row[Requests.messageId], row[Requests.userId], row[Requests.githubName], row[Requests.repoName]) }
182179
.firstOrNull()
183180
}
184181

@@ -203,7 +200,7 @@ fun getAllRequests(): List<Request> = transaction(database) {
203200
if (!Requests.exists()) return@transaction emptyList()
204201

205202
return@transaction Requests.selectAll()
206-
.map { row -> Request(row[Requests.messageId], row[Requests.threadId], row[Requests.userId], row[Requests.githubName], row[Requests.repoName]) }
203+
.map { row -> Request(row[Requests.messageId], row[Requests.userId], row[Requests.githubName], row[Requests.repoName]) }
207204
}
208205

209206
/**

src/main/kotlin/io/codemc/api/database/schema.kt

-6
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ object Requests : Table() {
4040
* The `message_id` column, representing the unique ID of the request according to Discord.
4141
*/
4242
val messageId: Column<Long> = long("message_id").uniqueIndex()
43-
/**
44-
* The `thread_id` column, representing the unique ID of the thread according to Discord.
45-
*/
46-
val threadId: Column<Long> = long("thread_id")
4743
/**
4844
* The `user_id` column, representing the unique ID of the Discord user.
4945
*/
@@ -63,14 +59,12 @@ object Requests : Table() {
6359
/**
6460
* Represents a request in the database.
6561
* @property messageId The unique ID of the request according to Discord.
66-
* @property threadId The unique ID of the thread according to Discord.
6762
* @property userId The unique ID of the Discord user.
6863
* @property githubName The GitHub username of the user.
6964
* @property repoName The name of the repository.
7065
*/
7166
data class Request(
7267
val messageId: Long,
73-
val threadId: Long,
7468
val userId: Long,
7569
val githubName: String,
7670
val repoName: String

src/test/kotlin/io/codemc/api/database/TestDatabase.kt

+4-5
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class TestDatabase {
113113
val githubName = "MyAuthor"
114114
val repoName = "MyRepo"
115115

116-
createRequest(messageId, 0L, userId, githubName, repoName)
116+
createRequest(messageId, userId, githubName, repoName)
117117

118118
val r = getRequest(messageId)
119119
assertNotNull(r)
@@ -131,7 +131,7 @@ class TestDatabase {
131131
val githubName = "MyAuthor"
132132
val repoName = "MyRepo"
133133

134-
createRequest(messageId, 0L, userId, githubName, repoName)
134+
createRequest(messageId, userId, githubName, repoName)
135135
assertNotNull(getRequest(messageId))
136136

137137
removeRequest(messageId)
@@ -147,7 +147,7 @@ class TestDatabase {
147147
456L
148148
)
149149

150-
requests.forEach { createRequest(it, 0L,0L, "Test", "Test") }
150+
requests.forEach { createRequest(it, 0L, "Test", "Test") }
151151
requests.forEach { assertNotNull(getRequest(it)) }
152152

153153
removeAllRequests()
@@ -164,12 +164,11 @@ class TestDatabase {
164164
456L
165165
)
166166

167-
requests.forEachIndexed { index, l -> createRequest(l, 0L, index.toLong(), "Test", "Test") }
167+
requests.forEachIndexed { index, l -> createRequest(l, index.toLong(), "Test", "Test") }
168168
requests.forEachIndexed { index, l ->
169169
val r = getRequest(l)
170170
assertNotNull(r)
171171
assertEquals(index.toLong(), r?.userId)
172-
assertEquals(0L, r?.threadId)
173172
assertEquals("Test", r?.githubName)
174173
assertEquals("Test", r?.repoName)
175174
}

0 commit comments

Comments
 (0)