Mirror of @tangled.org/core. Running on a Raspberry Pi Zero 2

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

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

authored by anirudh.fi and committed by tangled.org 332c39c6 1a682db3

+20 -4
+9 -1
appview/db/db.go
··· 260 260 did text not null, 261 261 262 262 -- data 263 + avatar text, 263 264 description text not null, 264 265 include_bluesky integer not null default 0, 265 266 location text, ··· 1079 1078 // transfer data, constructing pull_at from pulls table 1080 1079 _, err = tx.Exec(` 1081 1080 insert into pull_submissions_new (id, pull_at, round_number, patch, created) 1082 - select 1081 + select 1083 1082 ps.id, 1084 1083 'at://' || p.owner_did || '/sh.tangled.repo.pull/' || p.rkey, 1085 1084 ps.round_number, ··· 1170 1169 1171 1170 create index if not exists idx_stars_created on stars(created); 1172 1171 create index if not exists idx_stars_subject_at_created on stars(subject_at, created); 1172 + `) 1173 + return err 1174 + }) 1175 + 1176 + orm.RunMigration(conn, logger, "add-avatar-to-profile", func(tx *sql.Tx) error { 1177 + _, err := tx.Exec(` 1178 + alter table profile add column avatar text; 1173 1179 `) 1174 1180 return err 1175 1181 })
+10 -3
appview/db/profile.go
··· 158 158 _, err = tx.Exec( 159 159 `insert or replace into profile ( 160 160 did, 161 + avatar, 161 162 description, 162 163 include_bluesky, 163 164 location, 164 165 pronouns 165 166 ) 166 - values (?, ?, ?, ?, ?)`, 167 + values (?, ?, ?, ?, ?, ?)`, 167 168 profile.Did, 169 + profile.Avatar, 168 170 profile.Description, 169 171 includeBskyValue, 170 172 profile.Location, ··· 349 347 func GetProfile(e Execer, did string) (*models.Profile, error) { 350 348 var profile models.Profile 351 349 var pronouns sql.Null[string] 350 + var avatar sql.Null[string] 352 351 353 352 profile.Did = did 354 353 355 354 includeBluesky := 0 356 355 357 356 err := e.QueryRow( 358 - `select description, include_bluesky, location, pronouns from profile where did = ?`, 357 + `select avatar, description, include_bluesky, location, pronouns from profile where did = ?`, 359 358 did, 360 - ).Scan(&profile.Description, &includeBluesky, &profile.Location, &pronouns) 359 + ).Scan(&avatar, &profile.Description, &includeBluesky, &profile.Location, &pronouns) 361 360 if err == sql.ErrNoRows { 362 361 profile := models.Profile{} 363 362 profile.Did = did ··· 375 372 376 373 if pronouns.Valid { 377 374 profile.Pronouns = pronouns.V 375 + } 376 + 377 + if avatar.Valid { 378 + profile.Avatar = avatar.V 378 379 } 379 380 380 381 rows, err := e.Query(`select link from profile_links where did = ?`, did)
+1
appview/models/profile.go
··· 13 13 Did string 14 14 15 15 // data 16 + Avatar string // CID of the avatar blob 16 17 Description string 17 18 IncludeBluesky bool 18 19 Location string