MCPcopy Create free account
hub / github.com/pydio/cells / FirstAvailableSlot

Method FirstAvailableSlot

common/storage/sql/postgres.go:47–72  ·  view source on GitHub ↗
(tableName string, mpath *tree.MPath, levelKey string, mpathes ...string)

Source from the content-addressed store, hash-verified

45}
46
47func (p *postgresHelper) FirstAvailableSlot(tableName string, mpath *tree.MPath, levelKey string, mpathes ...string) (string, []any, int64, bool) {
48 var args []any
49 q := `
50WITH parsed_data AS (
51 SELECT
52 SPLIT_PART(` + p.Concat(mpathes...) + `, '.', ?)::int AS numPart
53 FROM "` + tableName + `" tr
54 WHERE level = ? AND ?
55)
56SELECT numPart + 1 AS num
57FROM parsed_data tr
58WHERE NOT EXISTS (
59 SELECT 1
60 FROM parsed_data tr2
61 WHERE tr2.numPart = tr.numPart + 1
62)
63ORDER BY num
64LIMIT 1
65`
66 level := mpath.Length() + 1
67 args = append(args, level)
68 args = append(args, level)
69 args = append(args, tree.MPathLike{Value: mpath})
70
71 return q, args, 3000, true
72}
73
74func (p *postgresHelper) ApplyOrderedUpdates(db *gorm.DB, tableName string, sets []OrderedUpdate, wheres []sql.NamedArg) (int64, error) {
75

Callers

nothing calls this directly

Calls 2

ConcatMethod · 0.95
LengthMethod · 0.80

Tested by

no test coverage detected