Skip to content

Commit

Permalink
introduce github_gid (to be renamed)
Browse files Browse the repository at this point in the history
  • Loading branch information
chriku committed Oct 18, 2024
1 parent b7bc985 commit cd8b4c9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,10 @@ fragment IssueData on Issue {
}
query CurrentMetaData {
...MetaData
}
query FindUser($login: String!) {
...MetaData
user(login: $login) {
...UserData
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import gropius.sync.github.config.IMSConfig
import gropius.sync.github.config.IMSProjectConfig
import gropius.sync.github.generated.fragment.LabelData
import gropius.sync.github.generated.fragment.UserData
import gropius.sync.github.generated.fragment.UserData.Companion.asNode
import gropius.sync.github.generated.fragment.UserData.Companion.asUser
import gropius.sync.model.LabelInfo
import gropius.sync.repository.LabelInfoRepository
Expand Down Expand Up @@ -115,6 +116,12 @@ class GithubDataService(
val databaseId = userData?.asUser()?.databaseId
val encodedAccountId =
jsonNodeMapper.jsonNodeToDeterministicString(objectMapper.valueToTree<JsonNode>(databaseId ?: 0))
val encodedUserId =
jsonNodeMapper.jsonNodeToDeterministicString(
objectMapper.valueToTree<JsonNode>(
userData?.asNode()?.id ?: ""
)
)
val username = userData?.login ?: FALLBACK_USER_NAME
val ims = neoOperations.findById<IMS>(imsProject.ims().value.rawId!!)!!
if (databaseId != null) {
Expand All @@ -133,7 +140,7 @@ class GithubDataService(
userData?.asUser()?.email,
null,
username,
mutableMapOf("github_id" to encodedAccountId)
mutableMapOf("github_id" to encodedAccountId, "github_gid" to encodedUserId)
)
imsUser.ims().value = imsProject.ims().value
imsUser.template().value = imsUser.ims().value.template().value.imsUserTemplate().value
Expand Down
4 changes: 2 additions & 2 deletions sync-github/src/main/kotlin/gropius/sync/github/GithubSync.kt
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ final class GithubSync(
if (assignedUser as? IMSUser != null) listOf(assignedUser) else if (assignedUser as? GropiusUser != null) assignedUser.imsUsers()
.filter { it.ims().value == imsProject.ims().value } else emptyList()
val ids = imsUsers.map {
it.templatedFields["github_id"]!!
githubDataService.objectMapper.readTree(it.templatedFields["github_gid"]!!).textValue()
}
if (ids.isEmpty()) {
return null
Expand All @@ -216,7 +216,7 @@ final class GithubSync(
if (assignedUser as? IMSUser != null) listOf(assignedUser) else if (assignedUser as? GropiusUser != null) assignedUser.imsUsers()
.filter { it.ims().value == imsProject.ims().value } else emptyList()
val ids = imsUsers.map {
it.templatedFields["github_id"]!!
githubDataService.objectMapper.readTree(it.templatedFields["github_gid"]!!).textValue()
}
if (ids.isEmpty()) {
return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ class IMSConfigManager(
"github_id" to obj {
"nullable" to true
"type" to "int32"
}.toString(),
"github_gid" to obj {
"nullable" to true
"type" to "string"
}.toString()
)
}
Expand Down

0 comments on commit cd8b4c9

Please sign in to comment.