feat(server): allow unlimited project thread retrieval (#2976)

* feat(server): allow unlimited project thread retrieval

* Remove limit from frontend

---------

Co-authored-by: andrewwallacespeckle <andrew@speckle.systems>
This commit is contained in:
Kristaps Fabians Geikins
2024-09-12 18:15:14 +03:00
committed by GitHub
parent 6197ac1f40
commit ee41c83df7
8 changed files with 27 additions and 15 deletions
@@ -296,7 +296,7 @@ const documents = {
"\n query ViewerLoadedResources(\n $projectId: String!\n $modelIds: [String!]!\n $versionIds: [String!]\n ) {\n project(id: $projectId) {\n id\n role\n allowPublicComments\n models(filter: { ids: $modelIds }) {\n totalCount\n items {\n id\n name\n updatedAt\n loadedVersion: versions(\n filter: { priorityIds: $versionIds, priorityIdsOnly: true }\n ) {\n items {\n ...ViewerModelVersionCardItem\n automationsStatus {\n id\n automationRuns {\n ...AutomateViewerPanel_AutomateRun\n }\n }\n }\n }\n versions(limit: 5) {\n totalCount\n cursor\n items {\n ...ViewerModelVersionCardItem\n }\n }\n }\n }\n ...ProjectPageLatestItemsModels\n ...ModelPageProject\n ...HeaderNavShare_Project\n }\n }\n": types.ViewerLoadedResourcesDocument,
"\n query ViewerModelVersions(\n $projectId: String!\n $modelId: String!\n $versionsCursor: String\n ) {\n project(id: $projectId) {\n id\n role\n model(id: $modelId) {\n id\n versions(cursor: $versionsCursor, limit: 5) {\n totalCount\n cursor\n items {\n ...ViewerModelVersionCardItem\n }\n }\n }\n }\n }\n": types.ViewerModelVersionsDocument,
"\n query ViewerDiffVersions(\n $projectId: String!\n $modelId: String!\n $versionAId: String!\n $versionBId: String!\n ) {\n project(id: $projectId) {\n id\n model(id: $modelId) {\n id\n versionA: version(id: $versionAId) {\n ...ViewerModelVersionCardItem\n }\n versionB: version(id: $versionBId) {\n ...ViewerModelVersionCardItem\n }\n }\n }\n }\n": types.ViewerDiffVersionsDocument,
"\n query ViewerLoadedThreads(\n $projectId: String!\n $filter: ProjectCommentsFilter!\n $cursor: String\n $limit: Int = 25\n ) {\n project(id: $projectId) {\n id\n commentThreads(filter: $filter, cursor: $cursor, limit: $limit) {\n totalCount\n totalArchivedCount\n items {\n ...ViewerCommentThread\n ...LinkableComment\n }\n }\n }\n }\n": types.ViewerLoadedThreadsDocument,
"\n query ViewerLoadedThreads(\n $projectId: String!\n $filter: ProjectCommentsFilter!\n $cursor: String\n $limit: Int\n ) {\n project(id: $projectId) {\n id\n commentThreads(filter: $filter, cursor: $cursor, limit: $limit) {\n totalCount\n totalArchivedCount\n items {\n ...ViewerCommentThread\n ...LinkableComment\n }\n }\n }\n }\n": types.ViewerLoadedThreadsDocument,
"\n query ViewerRawProjectObject($projectId: String!, $objectId: String!) {\n project(id: $projectId) {\n id\n object(id: $objectId) {\n id\n data\n }\n }\n }\n": types.ViewerRawProjectObjectDocument,
"\n subscription OnViewerUserActivityBroadcasted(\n $target: ViewerUpdateTrackingTarget!\n $sessionId: String!\n ) {\n viewerUserActivityBroadcasted(target: $target, sessionId: $sessionId) {\n userName\n userId\n user {\n ...LimitedUserAvatar\n }\n state\n status\n sessionId\n }\n }\n": types.OnViewerUserActivityBroadcastedDocument,
"\n subscription OnViewerCommentsUpdated($target: ViewerUpdateTrackingTarget!) {\n projectCommentsUpdated(target: $target) {\n id\n type\n comment {\n id\n parent {\n id\n }\n ...ViewerCommentThread\n }\n }\n }\n": types.OnViewerCommentsUpdatedDocument,
@@ -1475,7 +1475,7 @@ export function graphql(source: "\n query ViewerDiffVersions(\n $projectId:
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(source: "\n query ViewerLoadedThreads(\n $projectId: String!\n $filter: ProjectCommentsFilter!\n $cursor: String\n $limit: Int = 25\n ) {\n project(id: $projectId) {\n id\n commentThreads(filter: $filter, cursor: $cursor, limit: $limit) {\n totalCount\n totalArchivedCount\n items {\n ...ViewerCommentThread\n ...LinkableComment\n }\n }\n }\n }\n"): (typeof documents)["\n query ViewerLoadedThreads(\n $projectId: String!\n $filter: ProjectCommentsFilter!\n $cursor: String\n $limit: Int = 25\n ) {\n project(id: $projectId) {\n id\n commentThreads(filter: $filter, cursor: $cursor, limit: $limit) {\n totalCount\n totalArchivedCount\n items {\n ...ViewerCommentThread\n ...LinkableComment\n }\n }\n }\n }\n"];
export function graphql(source: "\n query ViewerLoadedThreads(\n $projectId: String!\n $filter: ProjectCommentsFilter!\n $cursor: String\n $limit: Int\n ) {\n project(id: $projectId) {\n id\n commentThreads(filter: $filter, cursor: $cursor, limit: $limit) {\n totalCount\n totalArchivedCount\n items {\n ...ViewerCommentThread\n ...LinkableComment\n }\n }\n }\n }\n"): (typeof documents)["\n query ViewerLoadedThreads(\n $projectId: String!\n $filter: ProjectCommentsFilter!\n $cursor: String\n $limit: Int\n ) {\n project(id: $projectId) {\n id\n commentThreads(filter: $filter, cursor: $cursor, limit: $limit) {\n totalCount\n totalArchivedCount\n items {\n ...ViewerCommentThread\n ...LinkableComment\n }\n }\n }\n }\n"];
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
File diff suppressed because one or more lines are too long
@@ -119,7 +119,7 @@ export const viewerLoadedThreadsQuery = graphql(`
$projectId: String!
$filter: ProjectCommentsFilter!
$cursor: String
$limit: Int = 25
$limit: Int
) {
project(id: $projectId) {
id
@@ -25,7 +25,7 @@ extend type Project {
"""
commentThreads(
cursor: String
limit: Int! = 25
limit: Int
filter: ProjectCommentsFilter
): ProjectCommentCollection!
@@ -30,7 +30,7 @@ import {
} from '@/modules/shared/helpers/dbHelper'
import { Knex } from 'knex'
import { decodeCursor, encodeCursor } from '@/modules/shared/helpers/graphqlHelper'
import { SpeckleViewer } from '@speckle/shared'
import { isNullOrUndefined, SpeckleViewer } from '@speckle/shared'
import { SmartTextEditorValueSchema } from '@/modules/core/services/richTextEditorService'
import { Merge } from 'type-fest'
import { getBranchLatestCommits } from '@/modules/core/repositories/branches'
@@ -462,7 +462,7 @@ export async function getPaginatedBranchCommentsTotalCount(
export type PaginatedProjectCommentsParams = {
projectId: string
limit: number
limit?: MaybeNullOrUndefined<number>
cursor?: MaybeNullOrUndefined<string>
filter?: MaybeNullOrUndefined<
Partial<{
@@ -620,11 +620,23 @@ export async function getPaginatedProjectComments(
}
) {
const { cursor } = params
const limit = clamp(params.limit, 0, 100)
if (!limit) return { items: [], cursor: null }
let limit: Optional<number> = undefined
// If undefined limit, no limit at all - we need this for the viewer, where we kinda have to show all threads in the 3D space
if (!isNullOrUndefined(params.limit)) {
limit = Math.max(0, params.limit || 0)
// limit=0, return nothing (req probably only interested in totalCount)
if (!limit) return { items: [], cursor: null }
}
const { baseQuery } = await getPaginatedProjectCommentsBaseQuery(params, options)
const q = baseQuery.orderBy(Comments.col.createdAt, 'desc').limit(limit)
const q = baseQuery.orderBy(Comments.col.createdAt, 'desc')
if (limit) {
q.limit(limit)
}
if (cursor) {
q.andWhere(Comments.col.createdAt, '<', decodeCursor(cursor))
@@ -1877,7 +1877,7 @@ export type ProjectCommentArgs = {
export type ProjectCommentThreadsArgs = {
cursor?: InputMaybe<Scalars['String']['input']>;
filter?: InputMaybe<ProjectCommentsFilter>;
limit?: Scalars['Int']['input'];
limit?: InputMaybe<Scalars['Int']['input']>;
};
@@ -5443,7 +5443,7 @@ export type ProjectResolvers<ContextType = GraphQLContext, ParentType extends Re
blob?: Resolver<Maybe<ResolversTypes['BlobMetadata']>, ParentType, ContextType, RequireFields<ProjectBlobArgs, 'id'>>;
blobs?: Resolver<Maybe<ResolversTypes['BlobMetadataCollection']>, ParentType, ContextType, RequireFields<ProjectBlobsArgs, 'cursor' | 'limit' | 'query'>>;
comment?: Resolver<Maybe<ResolversTypes['Comment']>, ParentType, ContextType, RequireFields<ProjectCommentArgs, 'id'>>;
commentThreads?: Resolver<ResolversTypes['ProjectCommentCollection'], ParentType, ContextType, RequireFields<ProjectCommentThreadsArgs, 'limit'>>;
commentThreads?: Resolver<ResolversTypes['ProjectCommentCollection'], ParentType, ContextType, Partial<ProjectCommentThreadsArgs>>;
createdAt?: Resolver<ResolversTypes['DateTime'], ParentType, ContextType>;
description?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
@@ -1863,7 +1863,7 @@ export type ProjectCommentArgs = {
export type ProjectCommentThreadsArgs = {
cursor?: InputMaybe<Scalars['String']['input']>;
filter?: InputMaybe<ProjectCommentsFilter>;
limit?: Scalars['Int']['input'];
limit?: InputMaybe<Scalars['Int']['input']>;
};
@@ -1864,7 +1864,7 @@ export type ProjectCommentArgs = {
export type ProjectCommentThreadsArgs = {
cursor?: InputMaybe<Scalars['String']['input']>;
filter?: InputMaybe<ProjectCommentsFilter>;
limit?: Scalars['Int']['input'];
limit?: InputMaybe<Scalars['Int']['input']>;
};