···
func GetProfile(e Execer, did string) (*Profile, error) {
···
+
func GetProfiles(e Execer, filters ...filter) ([]Profile, error) {
+
var conditions []string
+
for _, filter := range filters {
+
conditions = append(conditions, filter.Condition())
+
args = append(args, filter.Arg()...)
+
whereClause = " where " + strings.Join(conditions, " and ")
+
profilesQuery := fmt.Sprintf(
+
rows, err := e.Query(profilesQuery, args...)
+
profileMap := make(map[string]*Profile)
+
err = rows.Scan(&profile.ID, &profile.Did, &profile.Description, &includeBluesky, &profile.Location)
+
if includeBluesky != 0 {
+
profile.IncludeBluesky = true
+
profileMap[profile.Did] = &profile
+
if err = rows.Err(); err != nil {
+
// populate profile links
+
inClause := strings.TrimSuffix(strings.Repeat("?, ", len(profileMap)), ", ")
+
args = make([]any, len(profileMap))
+
for did := range profileMap {
+
linksQuery := fmt.Sprintf("select link, did from profile_links where did in (%s)", inClause)
+
rows, err = e.Query(linksQuery, args...)
+
idxs := make(map[string]int)
+
for did := range profileMap {
+
if err = rows.Scan(&link, &did); err != nil {
+
log.Println("idx", "idx", idx, "link", link)
+
profileMap[did].Links[idx] = link
+
pinsQuery := fmt.Sprintf("select at_uri, did from profile_pinned_repositories where did in (%s)", inClause)
+
rows, err = e.Query(pinsQuery, args...)
+
idxs = make(map[string]int)
+
for did := range profileMap {
+
if err = rows.Scan(&link, &did); err != nil {
+
profileMap[did].PinnedRepos[idx] = link
+
for _, p := range profileMap {
+
profiles = append(profiles, *p)
func GetProfile(e Execer, did string) (*Profile, error) {