Monorepo for Tangled tangled.org

appview/{db,models}: add avatar to profile

Signed-off-by: Anirudh Oppiliappan <anirudh@tangled.org>

anirudh.fi 67062d30 bdaa3c1e

verified
+20 -4
+9 -1
appview/db/db.go
··· 260 did text not null, 261 262 -- data 263 description text not null, 264 include_bluesky integer not null default 0, 265 location text, ··· 1078 // transfer data, constructing pull_at from pulls table 1079 _, err = tx.Exec(` 1080 insert into pull_submissions_new (id, pull_at, round_number, patch, created) 1081 - select 1082 ps.id, 1083 'at://' || p.owner_did || '/sh.tangled.repo.pull/' || p.rkey, 1084 ps.round_number, ··· 1169 1170 create index if not exists idx_stars_created on stars(created); 1171 create index if not exists idx_stars_subject_at_created on stars(subject_at, created); 1172 `) 1173 return err 1174 })
··· 260 did text not null, 261 262 -- data 263 + avatar text, 264 description text not null, 265 include_bluesky integer not null default 0, 266 location text, ··· 1079 // transfer data, constructing pull_at from pulls table 1080 _, err = tx.Exec(` 1081 insert into pull_submissions_new (id, pull_at, round_number, patch, created) 1082 + select 1083 ps.id, 1084 'at://' || p.owner_did || '/sh.tangled.repo.pull/' || p.rkey, 1085 ps.round_number, ··· 1170 1171 create index if not exists idx_stars_created on stars(created); 1172 create index if not exists idx_stars_subject_at_created on stars(subject_at, created); 1173 + `) 1174 + return err 1175 + }) 1176 + 1177 + orm.RunMigration(conn, logger, "add-avatar-to-profile", func(tx *sql.Tx) error { 1178 + _, err := tx.Exec(` 1179 + alter table profile add column avatar text; 1180 `) 1181 return err 1182 })
+10 -3
appview/db/profile.go
··· 135 _, err = tx.Exec( 136 `insert or replace into profile ( 137 did, 138 description, 139 include_bluesky, 140 location, 141 pronouns 142 ) 143 - values (?, ?, ?, ?, ?)`, 144 profile.Did, 145 profile.Description, 146 includeBskyValue, 147 profile.Location, ··· 324 func GetProfile(e Execer, did string) (*models.Profile, error) { 325 var profile models.Profile 326 var pronouns sql.Null[string] 327 328 profile.Did = did 329 330 includeBluesky := 0 331 332 err := e.QueryRow( 333 - `select description, include_bluesky, location, pronouns from profile where did = ?`, 334 did, 335 - ).Scan(&profile.Description, &includeBluesky, &profile.Location, &pronouns) 336 if err == sql.ErrNoRows { 337 profile := models.Profile{} 338 profile.Did = did ··· 349 350 if pronouns.Valid { 351 profile.Pronouns = pronouns.V 352 } 353 354 rows, err := e.Query(`select link from profile_links where did = ?`, did)
··· 135 _, err = tx.Exec( 136 `insert or replace into profile ( 137 did, 138 + avatar, 139 description, 140 include_bluesky, 141 location, 142 pronouns 143 ) 144 + values (?, ?, ?, ?, ?, ?)`, 145 profile.Did, 146 + profile.Avatar, 147 profile.Description, 148 includeBskyValue, 149 profile.Location, ··· 326 func GetProfile(e Execer, did string) (*models.Profile, error) { 327 var profile models.Profile 328 var pronouns sql.Null[string] 329 + var avatar sql.Null[string] 330 331 profile.Did = did 332 333 includeBluesky := 0 334 335 err := e.QueryRow( 336 + `select avatar, description, include_bluesky, location, pronouns from profile where did = ?`, 337 did, 338 + ).Scan(&avatar, &profile.Description, &includeBluesky, &profile.Location, &pronouns) 339 if err == sql.ErrNoRows { 340 profile := models.Profile{} 341 profile.Did = did ··· 352 353 if pronouns.Valid { 354 profile.Pronouns = pronouns.V 355 + } 356 + 357 + if avatar.Valid { 358 + profile.Avatar = avatar.V 359 } 360 361 rows, err := e.Query(`select link from profile_links where did = ?`, did)
+1
appview/models/profile.go
··· 13 Did string 14 15 // data 16 Description string 17 IncludeBluesky bool 18 Location string
··· 13 Did string 14 15 // data 16 + Avatar string // CID of the avatar blob 17 Description string 18 IncludeBluesky bool 19 Location string