MCPcopy Index your code
hub / github.com/cloudreve/cloudreve / withFileEagerLoading

Function withFileEagerLoading

inventory/file_utils.go:331–359  ·  view source on GitHub ↗
(ctx context.Context, q *ent.FileQuery)

Source from the content-addressed store, hash-verified

329}
330
331func withFileEagerLoading(ctx context.Context, q *ent.FileQuery) *ent.FileQuery {
332 if v, ok := ctx.Value(LoadFileEntity{}).(bool); ok && v {
333 q.WithEntities(func(m *ent.EntityQuery) {
334 m.Order(ent.Desc(entity.FieldID))
335 withEntityEagerLoading(ctx, m)
336 })
337 }
338 if v, ok := ctx.Value(LoadFileMetadata{}).(bool); ok && v {
339 q.WithMetadata()
340 }
341 if v, ok := ctx.Value(LoadFilePublicMetadata{}).(bool); ok && v {
342 q.WithMetadata(func(m *ent.MetadataQuery) {
343 m.Where(metadata.IsPublic(true))
344 })
345 }
346 if v, ok := ctx.Value(LoadFileShare{}).(bool); ok && v {
347 q.WithShares()
348 }
349 if v, ok := ctx.Value(LoadFileUser{}).(bool); ok && v {
350 q.WithOwner(func(query *ent.UserQuery) {
351 withUserEagerLoading(ctx, query)
352 })
353 }
354 if v, ok := ctx.Value(LoadFileDirectLink{}).(bool); ok && v {
355 q.WithDirectLinks()
356 }
357
358 return q
359}
360
361func withEntityEagerLoading(ctx context.Context, q *ent.EntityQuery) *ent.EntityQuery {
362 if v, ok := ctx.Value(LoadEntityUser{}).(bool); ok && v {

Callers 10

GetByHashIDMethod · 0.85
GetParentFileMethod · 0.85
GetChildFileMethod · 0.85
GetChildFilesMethod · 0.85
GetByIDMethod · 0.85
GetByIDsMethod · 0.85
FlattenListFilesMethod · 0.85
withShareEagerLoadingFunction · 0.85
withEntityEagerLoadingFunction · 0.85

Calls 12

DescFunction · 0.92
IsPublicFunction · 0.92
withEntityEagerLoadingFunction · 0.85
withUserEagerLoadingFunction · 0.85
WithMetadataMethod · 0.80
WithDirectLinksMethod · 0.80
OrderMethod · 0.65
ValueMethod · 0.45
WithEntitiesMethod · 0.45
WhereMethod · 0.45
WithSharesMethod · 0.45
WithOwnerMethod · 0.45

Tested by

no test coverage detected