Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package zed.rainxch.core.data.dto

import kotlinx.serialization.Serializable

@Serializable
data class BackendExploreResponse(
val items: List<BackendRepoResponse>,
val page: Int,
val hasMore: Boolean,
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import io.ktor.client.request.parameter
import io.ktor.http.isSuccess
import io.ktor.serialization.kotlinx.json.json
import kotlinx.serialization.json.Json
import io.ktor.client.plugins.timeout
import zed.rainxch.core.data.dto.BackendExploreResponse
import zed.rainxch.core.data.dto.BackendRepoResponse
import zed.rainxch.core.data.dto.BackendSearchResponse
import kotlin.coroutines.cancellation.CancellationException
Expand Down Expand Up @@ -73,6 +75,25 @@ class BackendApiClient {
}
}

suspend fun searchExplore(
query: String,
platform: String? = null,
page: Int = 1,
): Result<BackendExploreResponse> =
safeCall {
val response = httpClient.get("search/explore") {
parameter("q", query)
if (platform != null) parameter("platform", platform)
parameter("page", page)
timeout { requestTimeoutMillis = 20_000 }
}
if (response.status.isSuccess()) {
Result.success(response.body())
} else {
Result.failure(BackendException("HTTP ${response.status.value}"))
}
}

suspend fun getRepo(owner: String, name: String): Result<BackendRepoResponse> =
safeCall {
val response = httpClient.get("repo/$owner/$name")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@
<string name="downloads">التنزيلات</string>
<string name="license">الترخيص</string>
<string name="license_none">لا يوجد</string>
<string name="fetch_more_from_github">جلب المزيد من GitHub</string>
<string name="fetching_from_github">جارٍ الجلب من GitHub…</string>
<string name="no_more_github_results">لا توجد نتائج أخرى على GitHub</string>
<string name="explore_error">فشل الجلب من GitHub. حاول مرة أخرى.</string>

<!-- Misc -->
<string name="by_author">بواسطة %1$s</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@
<string name="downloads">ডাউনলোড</string>
<string name="license">লাইসেন্স</string>
<string name="license_none">নেই</string>
<string name="fetch_more_from_github">GitHub থেকে আরও আনুন</string>
<string name="fetching_from_github">GitHub থেকে আনা হচ্ছে…</string>
<string name="no_more_github_results">GitHub-এ আর ফলাফল নেই</string>
<string name="explore_error">GitHub থেকে আনতে ব্যর্থ। আবার চেষ্টা করুন।</string>

<!-- Misc -->
<string name="by_author">%1$s দ্বারা</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@
<string name="downloads">Descargas</string>
<string name="license">Licencia</string>
<string name="license_none">Ninguna</string>
<string name="fetch_more_from_github">Buscar más en GitHub</string>
<string name="fetching_from_github">Buscando en GitHub…</string>
<string name="no_more_github_results">No hay más resultados en GitHub</string>
<string name="explore_error">Error al buscar en GitHub. Inténtalo de nuevo.</string>

<string name="by_author">por %1$s</string>
<string name="installed_version">• Instalado: %1$s</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@
<string name="downloads">Téléchargements</string>
<string name="license">Licence</string>
<string name="license_none">Aucune</string>
<string name="fetch_more_from_github">Chercher plus sur GitHub</string>
<string name="fetching_from_github">Recherche sur GitHub…</string>
<string name="no_more_github_results">Plus de résultats sur GitHub</string>
<string name="explore_error">Échec de la recherche GitHub. Réessayez.</string>

<string name="by_author">par %1$s</string>
<string name="installed_version">• Installé : %1$s</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@
<string name="downloads">डाउनलोड</string>
<string name="license">लाइसेंस</string>
<string name="license_none">कोई नहीं</string>
<string name="fetch_more_from_github">GitHub से और लाएं</string>
<string name="fetching_from_github">GitHub से ला रहे हैं…</string>
<string name="no_more_github_results">GitHub पर और परिणाम नहीं हैं</string>
<string name="explore_error">GitHub से लाने में विफल। पुनः प्रयास करें।</string>

<!-- Misc -->
<string name="by_author">द्वारा %1$s</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@
<string name="downloads">Download</string>
<string name="license">Licenza</string>
<string name="license_none">Nessuna</string>
<string name="fetch_more_from_github">Cerca altri su GitHub</string>
<string name="fetching_from_github">Ricerca su GitHub…</string>
<string name="no_more_github_results">Nessun altro risultato su GitHub</string>
<string name="explore_error">Ricerca GitHub fallita. Riprova.</string>

<!-- Misc -->
<string name="by_author">per %1$s</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@
<string name="downloads">ダウンロード</string>
<string name="license">ライセンス</string>
<string name="license_none">なし</string>
<string name="fetch_more_from_github">GitHubからさらに取得</string>
<string name="fetching_from_github">GitHubから取得中…</string>
<string name="no_more_github_results">GitHubにこれ以上の結果はありません</string>
<string name="explore_error">GitHubからの取得に失敗しました。再試行してください。</string>

<string name="by_author">%1$s 作</string>
<string name="installed_version">• インストール済み: %1$s</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@
<string name="downloads">다운로드</string>
<string name="license">라이선스</string>
<string name="license_none">없음</string>
<string name="fetch_more_from_github">GitHub에서 더 가져오기</string>
<string name="fetching_from_github">GitHub에서 가져오는 중…</string>
<string name="no_more_github_results">GitHub에 더 이상 결과가 없습니다</string>
<string name="explore_error">GitHub에서 가져오기 실패. 다시 시도하세요.</string>

<!-- Misc -->
<string name="by_author">%1$s 작성</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@
<string name="downloads">Pobrania</string>
<string name="license">Licencja</string>
<string name="license_none">Brak</string>
<string name="fetch_more_from_github">Pobierz więcej z GitHub</string>
<string name="fetching_from_github">Pobieranie z GitHub…</string>
<string name="no_more_github_results">Brak więcej wyników na GitHub</string>
<string name="explore_error">Nie udało się pobrać z GitHub. Spróbuj ponownie.</string>

<string name="by_author">autor: %1$s</string>
<string name="installed_version">• Zainstalowana: %1$s</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@
<string name="downloads">Загрузки</string>
<string name="license">Лицензия</string>
<string name="license_none">Нет</string>
<string name="fetch_more_from_github">Найти ещё на GitHub</string>
<string name="fetching_from_github">Поиск на GitHub…</string>
<string name="no_more_github_results">Больше результатов на GitHub нет</string>
<string name="explore_error">Не удалось загрузить с GitHub. Попробуйте снова.</string>

<string name="by_author">от %1$s</string>
<string name="installed_version">• Установлено: %1$s</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@
<string name="downloads">İndirmeler</string>
<string name="license">Lisans</string>
<string name="license_none">Yok</string>
<string name="fetch_more_from_github">GitHub\'tan daha fazla getir</string>
<string name="fetching_from_github">GitHub\'tan getiriliyor…</string>
<string name="no_more_github_results">GitHub\'ta başka sonuç yok</string>
<string name="explore_error">GitHub\'tan getirilemedi. Tekrar deneyin.</string>

<!-- Misc -->
<string name="by_author">%1$s</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@
<string name="downloads">下载量</string>
<string name="license">许可证</string>
<string name="license_none">无</string>
<string name="fetch_more_from_github">从 GitHub 获取更多</string>
<string name="fetching_from_github">正在从 GitHub 获取…</string>
<string name="no_more_github_results">GitHub 上没有更多结果</string>
<string name="explore_error">从 GitHub 获取失败,请重试。</string>

<string name="by_author">由 %1$s</string>
<string name="installed_version">• 已安装:%1$s</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,12 @@
<string name="license">License</string>
<string name="license_none">None</string>

<!-- Explore -->
<string name="fetch_more_from_github">Fetch more from GitHub</string>
<string name="fetching_from_github">Fetching from GitHub…</string>
<string name="no_more_github_results">No more results on GitHub</string>
<string name="explore_error">Failed to fetch from GitHub. Try again.</string>

<!-- Misc -->
<string name="by_author">by %1$s</string>
<string name="installed_version">• Installed: %1$s</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import zed.rainxch.core.domain.model.DiscoveryPlatform
import zed.rainxch.core.domain.model.GithubRepoSummary
import zed.rainxch.core.domain.model.PaginatedDiscoveryRepositories
import zed.rainxch.core.domain.model.RateLimitException
import zed.rainxch.domain.model.ExploreResult
import zed.rainxch.domain.model.ProgrammingLanguage
import zed.rainxch.domain.model.SortBy
import zed.rainxch.domain.model.SortOrder
Expand Down Expand Up @@ -426,4 +427,30 @@ class SearchRepositoryImpl(
}
return result
}

override suspend fun exploreFromGithub(
query: String,
platform: DiscoveryPlatform,
page: Int,
): ExploreResult {
val platformSlug = when (platform) {
DiscoveryPlatform.Android -> "android"
DiscoveryPlatform.Windows -> "windows"
DiscoveryPlatform.Macos -> "macos"
DiscoveryPlatform.Linux -> "linux"
DiscoveryPlatform.All -> null
}

val response = backendApiClient.searchExplore(
query = query,
platform = platformSlug,
page = page,
).getOrThrow()

return ExploreResult(
repos = response.items.map { it.toSummary() },
page = response.page,
hasMore = response.hasMore,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package zed.rainxch.domain.model

import zed.rainxch.core.domain.model.GithubRepoSummary

data class ExploreResult(
val repos: List<GithubRepoSummary>,
val page: Int,
val hasMore: Boolean,
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package zed.rainxch.domain.repository
import kotlinx.coroutines.flow.Flow
import zed.rainxch.core.domain.model.DiscoveryPlatform
import zed.rainxch.core.domain.model.PaginatedDiscoveryRepositories
import zed.rainxch.domain.model.ExploreResult
import zed.rainxch.domain.model.ProgrammingLanguage
import zed.rainxch.domain.model.SortBy
import zed.rainxch.domain.model.SortOrder
Expand All @@ -16,4 +17,10 @@ interface SearchRepository {
sortOrder: SortOrder,
page: Int,
): Flow<PaginatedDiscoveryRepositories>

suspend fun exploreFromGithub(
query: String,
platform: DiscoveryPlatform,
page: Int,
): ExploreResult
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,6 @@ sealed interface SearchAction {
) : SearchAction

data object OnClearAllHistory : SearchAction

data object ExploreFromGithub : SearchAction
}
Loading