Monorepo for Tangled

appview/db: remove profile vanity stats constraints

this allows ingesting newer types of stats.

Signed-off-by: oppiliappan <me@oppi.li>

+29 -2
+24
appview/db/db.go
··· 1181 return err 1182 }) 1183 1184 return &DB{ 1185 db, 1186 logger,
··· 1181 return err 1182 }) 1183 1184 + orm.RunMigration(conn, logger, "remove-profile-stats-column-constraint", func(tx *sql.Tx) error { 1185 + _, err := tx.Exec(` 1186 + -- create new table without the check constraint 1187 + create table profile_stats_new ( 1188 + id integer primary key autoincrement, 1189 + did text not null, 1190 + kind text not null, -- no constraint this time 1191 + foreign key (did) references profile(did) on delete cascade 1192 + ); 1193 + 1194 + -- copy data from old table 1195 + insert into profile_stats_new (id, did, kind) 1196 + select id, did, kind 1197 + from profile_stats; 1198 + 1199 + -- drop old table 1200 + drop table profile_stats; 1201 + 1202 + -- rename new table 1203 + alter table profile_stats_new rename to profile_stats; 1204 + `) 1205 + return err 1206 + }) 1207 + 1208 return &DB{ 1209 db, 1210 logger,
+3 -1
appview/db/profile.go
··· 451 query = `select count(id) from repos where did = ?` 452 args = append(args, did) 453 case models.VanityStatStarCount: 454 - query = `select count(id) from stars where did = ?` 455 args = append(args, did) 456 } 457 458 var result uint64
··· 451 query = `select count(id) from repos where did = ?` 452 args = append(args, did) 453 case models.VanityStatStarCount: 454 + query = `select count(id) from stars where subject_at like 'at://' || ? || '%'` 455 args = append(args, did) 456 + default: 457 + return 0, fmt.Errorf("invalid vanity stat kind: %s", stat) 458 } 459 460 var result uint64
+1 -1
appview/models/profile.go
··· 77 case VanityStatRepositoryCount: 78 return "Repositories" 79 case VanityStatStarCount: 80 - return "Stars" 81 } 82 return "" 83 }
··· 77 case VanityStatRepositoryCount: 78 return "Repositories" 79 case VanityStatStarCount: 80 + return "Stars Received" 81 } 82 return "" 83 }
+1
appview/pages/templates/user/fragments/editBio.html
··· 118 "open-issue-count" "Open Issue Count" 119 "closed-issue-count" "Closed Issue Count" 120 "repository-count" "Repository Count" 121 }} 122 {{ range $s := $stats }} 123 {{ $value := index $s 0 }}
··· 118 "open-issue-count" "Open Issue Count" 119 "closed-issue-count" "Closed Issue Count" 120 "repository-count" "Repository Count" 121 + "star-count" "Star Count" 122 }} 123 {{ range $s := $stats }} 124 {{ $value := index $s 0 }}