-
Notifications
You must be signed in to change notification settings - Fork 67
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
Improve document logs table perfomance #472
Conversation
|
||
import { Commit } from '../../browser' | ||
import { database } from '../../client' | ||
import { | ||
createDocumentLogQuery, | ||
getCommitFilter, | ||
} from './_createDocumentLogQuery' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I 🔥 this archive. Now all the "with metadata" things are in this file. I left a FIXME in evaluations to do the same
}) { | ||
const byDocumentUuid = documentUuid | ||
? eq(scope.documentUuid, documentUuid) | ||
: sql`1 = 1` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If documentUuid
is not passed we don't care and use 1 = 1
. This case is covering /evaluations
playground where we get a documentLog.resolvedContent
for the evaluation variables
We don't have the scope of documentUuid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm don't get it is this gonna match all document logs a pelo? in what scenario do we care about document logs without filtering by document uuid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the playground we can import any document log from any project and any document
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const documentLogUuid = uuid() | ||
let providerLogs: ProviderLog[] = [] | ||
|
||
if (!skipProviderLogs) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make provider logs creation optional on this factory
00a51ab
to
22655ba
Compare
Doing something similar to what we did with evaluation results where we filter by page and object the rows to be shown in the aggregated table of logs. This should improve performance
22655ba
to
c6a5943
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
export async function computeDocumentLogsWithMetadataCount( | ||
{ | ||
workspaceId, | ||
documentUuid, | ||
draft, | ||
}: { | ||
workspaceId: number | ||
documentUuid: string | ||
draft?: Commit | ||
}, | ||
db = database, | ||
) { | ||
const { scope } = getRepositoryScopes(workspaceId, db) | ||
|
||
const countList = await db | ||
.select({ | ||
count: sql<number>`count(*)`.as('total_count'), | ||
}) | ||
.from(scope) | ||
.innerJoin(commits, eq(commits.id, scope.commitId)) | ||
.where(getCommonQueryConditions({ scope, documentUuid, draft })) | ||
|
||
return countList?.[0]?.count ? Number(countList[0].count) : 0 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not "with metadata", could easily be moved to DocumentLogsRepository
. Although I get that you want to keep the getCommonQueryConditions
What?
Doing something similar to what we did with evaluation results, we filter by page and object the rows to be shown in the aggregated table of logs. This should improve performance
TODO