Fixed NPE, fixed failed lister migration.

main
mathan 2024-02-25 20:51:10 -08:00
parent 067be8ec83
commit efc106453f
3 changed files with 34 additions and 6 deletions

View File

@ -0,0 +1,23 @@
DROP VIEW posts;
DROP VIEW lists;
DROP VIEW listitems;
ALTER TABLE "records" ALTER COLUMN "deleted" TYPE boolean USING "deleted"::boolean;
create view posts as
select *, jsonb_extract_path(content, 'langs') as langs,
parse_timestamp(jsonb_extract_path_text(content, 'createdAt')) as content_created_at
from records_post;
create view lists as
select records_list.*,
jsonb_extract_path_text(content, 'name') as name,
jsonb_extract_path_text(content, 'description') as description,
jsonb_extract_path_text(content, 'purpose') as purpose,
'at://' || repos.did || '/app.bsky.graph.list/' || rkey as uri
from records_list join repos on records_list.repo = repos.id;
create view listitems as
select *, jsonb_extract_path_text(content, 'list') as list,
jsonb_extract_path_text(content, 'subject') as subject
from records_listitem;

View File

@ -1498,11 +1498,12 @@
"type": "prometheus", "type": "prometheus",
"uid": "PBFA97CFB590B2093" "uid": "PBFA97CFB590B2093"
}, },
"description": "Warranty: 1440 TBW total", "description": "Warranty: 1440 TBW or 3 years\n\nAcceptable TBW per day to last 3 years: 1.315068",
"fieldConfig": { "fieldConfig": {
"defaults": { "defaults": {
"mappings": [], "mappings": [],
"max": 1.315068, "max": 1.315068,
"min": 0,
"thresholds": { "thresholds": {
"mode": "percentage", "mode": "percentage",
"steps": [ "steps": [
@ -1511,16 +1512,20 @@
"value": null "value": null
}, },
{ {
"color": "blue", "color": "#6ED0E0",
"value": 25
},
{
"color": "#EAB839",
"value": 50 "value": 50
}, },
{ {
"color": "orange", "color": "orange",
"value": 75 "value": 70
}, },
{ {
"color": "red", "color": "red",
"value": 90 "value": 85
} }
] ]
}, },
@ -2764,6 +2769,6 @@
"timezone": "", "timezone": "",
"title": "Bsky indexer", "title": "Bsky indexer",
"uid": "aXw6dQhSzs", "uid": "aXw6dQhSzs",
"version": 38, "version": 39,
"weekStart": "" "weekStart": ""
} }

View File

@ -72,7 +72,7 @@ func EnsureExists(ctx context.Context, db *gorm.DB, did string) (*Repo, bool, er
remote, err := pds.EnsureExists(ctx, db, u.String()) remote, err := pds.EnsureExists(ctx, db, u.String())
if err != nil { if err != nil {
return nil, false, fmt.Errorf("failed to get PDS record from DB for %q: %w", remote.Host, err) return nil, false, fmt.Errorf("failed to get PDS record from DB: %w", err)
} }
r = Repo{DID: did, PDS: models.ID(remote.ID)} r = Repo{DID: did, PDS: models.ID(remote.ID)}
created := false created := false