mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-3167 Date as an Object | Exclude all object which were not created by space members (#1911)
This commit is contained in:
parent
85d64f7793
commit
1511babb0d
1 changed files with 37 additions and 14 deletions
|
@ -9,6 +9,9 @@ import com.anytypeio.anytype.core_models.ObjectTypeUniqueKeys
|
|||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.core_models.RelationFormat
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.Relations.LAST_MODIFIED_DATE
|
||||
import com.anytypeio.anytype.core_models.Relations.RELATION_KEY
|
||||
import com.anytypeio.anytype.core_models.Relations.TYPE
|
||||
import com.anytypeio.anytype.core_models.TimeInSeconds
|
||||
|
||||
fun filtersAndSortsForSearch(
|
||||
|
@ -21,8 +24,8 @@ fun filtersAndSortsForSearch(
|
|||
addAll(buildDeletedFilter())
|
||||
add(buildSpaceIdFilter(spaces))
|
||||
add(buildTemplateFilter())
|
||||
add(
|
||||
buildFieldFilter(
|
||||
addAll(
|
||||
buildFieldFilters(
|
||||
dateObjectId = dateId,
|
||||
field = field,
|
||||
timestamp = timestamp
|
||||
|
@ -45,31 +48,51 @@ private fun buildSorts(
|
|||
)
|
||||
}
|
||||
|
||||
private fun buildFieldFilter(
|
||||
private fun buildFieldFilters(
|
||||
dateObjectId: Id,
|
||||
field: ActiveField,
|
||||
timestamp: TimeInSeconds
|
||||
): DVFilter {
|
||||
): List<DVFilter> {
|
||||
val fieldKey = field.key.key
|
||||
return when (field.format) {
|
||||
Relation.Format.DATE -> {
|
||||
DVFilter(
|
||||
relation = fieldKey,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = timestamp.toDouble(),
|
||||
relationFormat = RelationFormat.DATE
|
||||
)
|
||||
buildList {
|
||||
add(
|
||||
DVFilter(
|
||||
relation = fieldKey,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = timestamp.toDouble(),
|
||||
relationFormat = RelationFormat.DATE
|
||||
)
|
||||
)
|
||||
if (fieldKey == LAST_MODIFIED_DATE) {
|
||||
add(
|
||||
DVFilter(
|
||||
relation = Relations.CREATED_DATE,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = mapOf(
|
||||
RELATION_KEY to fieldKey,
|
||||
TYPE to VALUE_FROM_RELATION
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
DVFilter(
|
||||
relation = fieldKey,
|
||||
condition = DVFilterCondition.IN,
|
||||
value = dateObjectId
|
||||
listOf(
|
||||
DVFilter(
|
||||
relation = fieldKey,
|
||||
condition = DVFilterCondition.IN,
|
||||
value = dateObjectId
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const val VALUE_FROM_RELATION = "valueFromRelation"
|
||||
|
||||
private fun buildTemplateFilter(): DVFilter = DVFilter(
|
||||
relation = Relations.TYPE_UNIQUE_KEY,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue