appview: associate users to commits by did #617

merged
opened by tjh.dev targeting master from tjh.dev/core: push-rwuynyxyuoxx
Changed files
+13 -9
appview
+13 -9
appview/db/email.go
··· 71 return did, nil 72 } 73 74 - func GetEmailToDid(e Execer, ems []string, isVerifiedFilter bool) (map[string]string, error) { 75 - if len(ems) == 0 { 76 return make(map[string]string), nil 77 } 78 ··· 81 verifiedFilter = 1 82 } 83 84 // Create placeholders for the IN clause 85 - placeholders := make([]string, len(ems)) 86 - args := make([]any, len(ems)+1) 87 88 args[0] = verifiedFilter 89 - for i, em := range ems { 90 - placeholders[i] = "?" 91 - args[i+1] = em 92 } 93 94 query := ` ··· 105 } 106 defer rows.Close() 107 108 - assoc := make(map[string]string) 109 - 110 for rows.Next() { 111 var email, did string 112 if err := rows.Scan(&email, &did); err != nil {
··· 71 return did, nil 72 } 73 74 + func GetEmailToDid(e Execer, emails []string, isVerifiedFilter bool) (map[string]string, error) { 75 + if len(emails) == 0 { 76 return make(map[string]string), nil 77 } 78 ··· 81 verifiedFilter = 1 82 } 83 84 + assoc := make(map[string]string) 85 + 86 // Create placeholders for the IN clause 87 + placeholders := make([]string, 0, len(emails)) 88 + args := make([]any, 1, len(emails)+1) 89 90 args[0] = verifiedFilter 91 + for _, email := range emails { 92 + if strings.HasPrefix(email, "did:") { 93 + assoc[email] = email 94 + continue 95 + } 96 + placeholders = append(placeholders, "?") 97 + args = append(args, email) 98 } 99 100 query := ` ··· 111 } 112 defer rows.Close() 113 114 for rows.Next() { 115 var email, did string 116 if err := rows.Scan(&email, &did); err != nil {