Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix several group page bugs #467

Merged
merged 3 commits into from
Nov 17, 2024
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
14 changes: 14 additions & 0 deletions app/src/main/graphql/FindGroups.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ query FindGroupTags($id: ID!) {
}
}

query CountGroupRelationships($filter: FindFilterType, $group_filter: GroupFilterType, $ids: [ID!]) {
findGroups(filter: $filter, group_filter: $group_filter, ids: $ids) {
groups {
id
sub_group_count
containing_groups {
group {
id
}
}
}
}
}

query FindGroupRelationships($filter: FindFilterType, $group_filter: GroupFilterType, $ids: [ID!]) {
findGroups(filter: $filter, group_filter: $group_filter, ids: $ids) {
groups {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class GroupFragment : TabbedFragment(DataType.GROUP.name) {
dataType = DataType.SCENE,
findFilter = groupSceneFilter.findFilter,
objectFilter =
(groupSceneFilter.objectFilter as SceneFilterType?)?.copy(
SceneFilterType(
groups =
Optional.present(
HierarchicalMultiCriterionInput(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ class GroupTagDataSupplier(private val groupId: String) :
}

override fun parseCountQuery(data: FindGroupTagsQuery.Data): Int {
return if (data.findGroup != null) {
1
} else {
0
}
return data.findGroup?.tags?.size ?: 0
}

override fun parseQuery(data: FindGroupTagsQuery.Data): List<TagData> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.damontecres.stashapp.suppliers

import com.apollographql.apollo.api.Query
import com.github.damontecres.stashapp.api.CountGroupsQuery
import com.github.damontecres.stashapp.api.CountGroupRelationshipsQuery
import com.github.damontecres.stashapp.api.FindGroupRelationshipsQuery
import com.github.damontecres.stashapp.api.type.FindFilterType
import com.github.damontecres.stashapp.data.DataType
Expand All @@ -13,7 +13,7 @@ class GroupRelationshipDataSupplier(
private val groupId: String,
private val type: GroupRelationshipType,
) :
StashPagingSource.DataSupplier<FindGroupRelationshipsQuery.Data, GroupRelationshipData, CountGroupsQuery.Data> {
StashPagingSource.DataSupplier<FindGroupRelationshipsQuery.Data, GroupRelationshipData, CountGroupRelationshipsQuery.Data> {
override val dataType: DataType get() = DataType.GROUP

override fun createQuery(filter: FindFilterType?): Query<FindGroupRelationshipsQuery.Data> {
Expand All @@ -28,12 +28,15 @@ class GroupRelationshipDataSupplier(
return DataType.GROUP.asDefaultFindFilterType
}

override fun createCountQuery(filter: FindFilterType?): Query<CountGroupsQuery.Data> {
return CountGroupsQuery(filter, null, listOf(groupId))
override fun createCountQuery(filter: FindFilterType?): Query<CountGroupRelationshipsQuery.Data> {
return CountGroupRelationshipsQuery(filter, null, listOf(groupId))
}

override fun parseCountQuery(data: CountGroupsQuery.Data): Int {
return data.findGroups.count
override fun parseCountQuery(data: CountGroupRelationshipsQuery.Data): Int {
return when (type) {
GroupRelationshipType.SUB -> data.findGroups.groups.firstOrNull()?.sub_group_count
GroupRelationshipType.CONTAINING -> data.findGroups.groups.firstOrNull()?.containing_groups?.size
} ?: 0
}

override fun parseQuery(data: FindGroupRelationshipsQuery.Data): List<GroupRelationshipData> {
Expand Down
Loading