MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / generateUniqueRandomTitle

Function generateUniqueRandomTitle

query/vector/vector_graphql_test.go:57–70  ·  view source on GitHub ↗
(existingTitles []ProjectInput)

Source from the content-addressed store, hash-verified

55}
56
57func generateUniqueRandomTitle(existingTitles []ProjectInput) string {
58 const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
59 const titleLength = 10
60 title := make([]byte, titleLength)
61 for {
62 for i := range title {
63 title[i] = charset[rand.Intn(len(charset))]
64 }
65 titleStr := string(title)
66 if !isTitleExists(titleStr, existingTitles) {
67 return titleStr
68 }
69 }
70}
71
72func generateRandomTitleV(size int) []float32 {
73 var titleV []float32

Callers 1

generateProjectsFunction · 0.85

Calls 1

isTitleExistsFunction · 0.85

Tested by

no test coverage detected