-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Find and clone repos from PORT (#198)
- Loading branch information
1 parent
3e9eadb
commit 05fe151
Showing
21 changed files
with
253 additions
and
37 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
query GetPrimaryReposQuery { | ||
GitRepos: git_repo( | ||
where: { | ||
content: { | ||
wa_content_metadata: { | ||
status: { | ||
_eq: "Primary" | ||
} | ||
} | ||
} | ||
} | ||
) { | ||
repoUrl: repo_url | ||
content { | ||
resourceType: resource_type | ||
language { | ||
languageCode: ietf_code | ||
} | ||
} | ||
} | ||
} |
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,62 @@ | ||
schema { | ||
query: Query | ||
} | ||
|
||
input String_comparison_exp { | ||
_eq: String | ||
} | ||
|
||
input git_repo_bool_exp { | ||
_and: [git_repo_bool_exp!] | ||
_not: git_repo_bool_exp | ||
_or: [git_repo_bool_exp!] | ||
content: content_bool_exp | ||
repo_name: String_comparison_exp | ||
repo_url: String_comparison_exp | ||
} | ||
|
||
input content_bool_exp { | ||
_and: [content_bool_exp!] | ||
_not: content_bool_exp | ||
_or: [content_bool_exp!] | ||
language: language_bool_exp | ||
resource_type: String_comparison_exp | ||
wa_content_metadata: wa_content_metadata_bool_exp | ||
} | ||
|
||
input wa_content_metadata_bool_exp { | ||
_and: [wa_content_metadata_bool_exp!] | ||
_not: wa_content_metadata_bool_exp | ||
_or: [wa_content_metadata_bool_exp!] | ||
status: String_comparison_exp | ||
} | ||
|
||
input language_bool_exp { | ||
_and: [language_bool_exp!] | ||
_not: language_bool_exp | ||
_or: [language_bool_exp!] | ||
ietf_code: String_comparison_exp | ||
} | ||
|
||
type Query { | ||
git_repo(where: git_repo_bool_exp): [Repo!]! | ||
} | ||
|
||
type Repo { | ||
repo_url: String | ||
content: Content | ||
} | ||
|
||
type Content { | ||
language: Language | ||
resource_type: String | ||
wa_content_metadata: [ContentMetadata] | ||
} | ||
|
||
type Language { | ||
ietf_code: String | ||
} | ||
|
||
type ContentMetadata { | ||
status: String | ||
} |
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
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
37 changes: 37 additions & 0 deletions
37
...c/main/kotlin/org/bibletranslationtools/fetcher/impl/repository/SourceTextAccessorImpl.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,37 @@ | ||
package org.bibletranslationtools.fetcher.impl.repository | ||
|
||
import com.apollographql.apollo3.ApolloClient | ||
import kotlinx.coroutines.runBlocking | ||
import org.bibletranslationtools.fetcher.graphql.generated.GetPrimaryReposQuery | ||
import org.bibletranslationtools.fetcher.repository.SourceTextAccessor | ||
|
||
class SourceTextAccessorImpl : SourceTextAccessor { | ||
private var cache: List<GetPrimaryReposQuery.GitRepo> = listOf() | ||
|
||
init { | ||
buildCache() | ||
} | ||
|
||
override fun update() { | ||
buildCache() | ||
} | ||
|
||
override fun getRepoUrl(languageCode: String, resourceId: String): String? { | ||
return cache.singleOrNull { | ||
it.content?.language?.languageCode == languageCode && | ||
it.content.resourceType == resourceId | ||
}?.repoUrl | ||
} | ||
|
||
private fun buildCache() { | ||
val client = ApolloClient.Builder() | ||
.serverUrl("https://api-biel-dev.walink.org/v1/graphql") | ||
.build() | ||
|
||
cache = runBlocking { | ||
val query = GetPrimaryReposQuery() | ||
val response = client.query(query).execute() | ||
response.data?.GitRepos ?: listOf() | ||
} | ||
} | ||
} |
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
10 changes: 10 additions & 0 deletions
10
.../src/main/kotlin/org/bibletranslationtools/fetcher/repository/RequestResourceContainer.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,10 @@ | ||
package org.bibletranslationtools.fetcher.repository | ||
|
||
import org.bibletranslationtools.fetcher.data.Deliverable | ||
import org.bibletranslationtools.fetcher.data.RCDeliverable | ||
import java.io.File | ||
|
||
interface RequestResourceContainer { | ||
fun getResourceContainer(deliverable: Deliverable): RCDeliverable? | ||
fun getResourceContainer(languageCode: String, resourceId: String): File? | ||
} |
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
...er-web/src/main/kotlin/org/bibletranslationtools/fetcher/repository/SourceTextAccessor.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 org.bibletranslationtools.fetcher.repository | ||
|
||
interface SourceTextAccessor { | ||
fun update() | ||
fun getRepoUrl(languageCode: String, resourceId: String): String? | ||
} |
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.