Skip to content

Commit cb41f92

Browse files
authored
Merge branch 'develop' into feature/explain-decompounding
2 parents 499e1b7 + 3cc735a commit cb41f92

File tree

8 files changed

+56
-4
lines changed

8 files changed

+56
-4
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88
google()
99
}
1010
dependencies {
11-
classpath("com.android.tools.build:gradle:3.5.0")
11+
classpath("com.android.tools.build:gradle:3.5.2")
1212
}
1313
}
1414

src/commonMain/kotlin/com/algolia/search/endpoint/EndpointMultiCluster.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,13 @@ public interface EndpointMultiCluster {
114114
clusterName: ClusterName,
115115
requestOptions: RequestOptions? = null
116116
): Creation
117+
118+
/**
119+
* @param retrieveMapping If set to true, retrieves [ResponseHasPendingMapping.clusters].
120+
* @param requestOptions Configure request locally with [RequestOptions].
121+
*/
122+
suspend fun hasPendingMapping(
123+
retrieveMapping: Boolean = false,
124+
requestOptions: RequestOptions? = null
125+
): ResponseHasPendingMapping
117126
}

src/commonMain/kotlin/com/algolia/search/endpoint/EndpointMulticlusterImpl.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,16 @@ internal class EndpointMulticlusterImpl(
8989

9090
return transport.request(HttpMethod.Post, CallType.Write, path, requestOptions, body)
9191
}
92+
93+
override suspend fun hasPendingMapping(
94+
retrieveMapping: Boolean,
95+
requestOptions: RequestOptions?
96+
): ResponseHasPendingMapping {
97+
val path = "$RouteClustersV1/mapping/pending"
98+
val options = requestOptionsBuilder(requestOptions) {
99+
parameter(KeyGetClusters, retrieveMapping)
100+
}
101+
102+
return transport.request(HttpMethod.Get, CallType.Read, path, options)
103+
}
92104
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.algolia.search.model.response
2+
3+
import com.algolia.search.model.multicluster.ClusterName
4+
import com.algolia.search.model.multicluster.UserID
5+
import kotlinx.serialization.SerialName
6+
import kotlinx.serialization.Serializable
7+
import com.algolia.search.serialize.KeyPending
8+
import com.algolia.search.serialize.KeyClusters
9+
10+
11+
@Serializable
12+
public data class ResponseHasPendingMapping(
13+
@SerialName(KeyPending) val isPending: Boolean,
14+
@SerialName(KeyClusters) val clusters: Map<ClusterName, List<UserID>>? = null
15+
)

src/commonMain/kotlin/com/algolia/search/model/synonym/Synonym.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ public sealed class Synonym {
4040
init {
4141
if (input.isBlank()) throw EmptyStringException("Input")
4242
if (synonyms.isEmpty()) throw EmptyListException("Synonyms")
43-
if (synonyms.size > 100) throw IllegalArgumentException("OneWay synonym have a maximum of 100 synonyms")
43+
require(synonyms.size <= limit) { "OneWay synonym have a maximum of $limit synonyms" }
44+
}
45+
46+
companion object {
47+
48+
private const val limit = 100
4449
}
4550
}
4651

@@ -54,7 +59,12 @@ public sealed class Synonym {
5459

5560
init {
5661
if (synonyms.isEmpty()) throw EmptyListException("Synonyms")
57-
if (synonyms.size > 20) throw IllegalArgumentException("OneWay synonym have a maximum of 100 synonyms")
62+
require(synonyms.size <= limit) { "OneWay synonym have a maximum of $limit synonyms" }
63+
}
64+
65+
companion object {
66+
67+
private const val limit = 20
5868
}
5969
}
6070

src/commonMain/kotlin/com/algolia/search/serialize/KeysTwo.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,6 @@ public const val KeyCompound = "compound"
184184
public const val KeyMatch = "match"
185185
public const val KeyTypos = "typos"
186186
public const val KeyMatchAlternatives = "match.alternatives"
187-
public const val KeyTypes = "types"
187+
public const val KeyTypes = "types"
188+
public const val KeyPending = "pending"
189+
public const val KeyGetClusters = "getClusters"

src/commonTest/kotlin/serialize/TestKeys.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,5 +372,7 @@ internal class TestKeys {
372372
KeyTypos shouldEqual "typos"
373373
KeyMatchAlternatives shouldEqual "match.alternatives"
374374
KeyTypes shouldEqual "types"
375+
KeyPending shouldEqual "pending"
376+
KeyGetClusters shouldEqual "getClusters"
375377
}
376378
}

src/commonTest/kotlin/suite/TestSuiteMultiCluster.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import kotlinx.coroutines.delay
1313
import kotlinx.coroutines.isActive
1414
import kotlinx.io.core.String
1515
import runBlocking
16+
import shouldBeFalse
1617
import shouldBeTrue
1718
import shouldEqual
1819
import shouldNotBeEmpty
@@ -87,6 +88,7 @@ internal class TestSuiteMultiCluster {
8788
clientMcm.listUserIDs().userIDs.filter { it.userID.raw.startsWith(prefix) }.forEach {
8889
clientMcm.removeUserID(it.userID)
8990
}
91+
clientMcm.hasPendingMapping(true).clusters.isNullOrEmpty().shouldBeFalse()
9092
}
9193
}
9294
}

0 commit comments

Comments
 (0)