Monorepo for Tangled tangled.org

appview,lexicons: atprotate the mentions & references #761

merged opened by boltless.me targeting master from feat/mentions

Storing references parsed from the markdown body in atproto record and DB. There can be lots of reference types considering the from/to types so storing both as AT-URIs

Using sql.Tx more to combine multiple DB query to single recoverable operation.

Note: Pulls don't have mentinos/references yet

Signed-off-by: Seongmin Lee git@boltless.me

Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:xasnlahkri4ewmbuzly2rlc5/sh.tangled.repo.pull/3m4vklvknse22
+178 -2
Interdiff #7 #8
+162 -2
api/tangled/cbor_gen.go
··· 7934 7934 } 7935 7935 7936 7936 cw := cbg.NewCborWriter(w) 7937 - fieldCount := 7 7937 + fieldCount := 9 7938 7938 7939 7939 if t.Body == nil { 7940 7940 fieldCount-- 7941 7941 } 7942 7942 7943 + if t.Mentions == nil { 7944 + fieldCount-- 7945 + } 7946 + 7947 + if t.References == nil { 7948 + fieldCount-- 7949 + } 7950 + 7943 7951 if t.Source == nil { 7944 7952 fieldCount-- 7945 7953 } ··· 8080 8088 return err 8081 8089 } 8082 8090 8091 + // t.Mentions ([]string) (slice) 8092 + if t.Mentions != nil { 8093 + 8094 + if len("mentions") > 1000000 { 8095 + return xerrors.Errorf("Value in field \"mentions\" was too long") 8096 + } 8097 + 8098 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("mentions"))); err != nil { 8099 + return err 8100 + } 8101 + if _, err := cw.WriteString(string("mentions")); err != nil { 8102 + return err 8103 + } 8104 + 8105 + if len(t.Mentions) > 8192 { 8106 + return xerrors.Errorf("Slice value in field t.Mentions was too long") 8107 + } 8108 + 8109 + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Mentions))); err != nil { 8110 + return err 8111 + } 8112 + for _, v := range t.Mentions { 8113 + if len(v) > 1000000 { 8114 + return xerrors.Errorf("Value in field v was too long") 8115 + } 8116 + 8117 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil { 8118 + return err 8119 + } 8120 + if _, err := cw.WriteString(string(v)); err != nil { 8121 + return err 8122 + } 8123 + 8124 + } 8125 + } 8126 + 8083 8127 // t.CreatedAt (string) (string) 8084 8128 if len("createdAt") > 1000000 { 8085 8129 return xerrors.Errorf("Value in field \"createdAt\" was too long") ··· 8102 8146 if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { 8103 8147 return err 8104 8148 } 8149 + 8150 + // t.References ([]string) (slice) 8151 + if t.References != nil { 8152 + 8153 + if len("references") > 1000000 { 8154 + return xerrors.Errorf("Value in field \"references\" was too long") 8155 + } 8156 + 8157 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("references"))); err != nil { 8158 + return err 8159 + } 8160 + if _, err := cw.WriteString(string("references")); err != nil { 8161 + return err 8162 + } 8163 + 8164 + if len(t.References) > 8192 { 8165 + return xerrors.Errorf("Slice value in field t.References was too long") 8166 + } 8167 + 8168 + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.References))); err != nil { 8169 + return err 8170 + } 8171 + for _, v := range t.References { 8172 + if len(v) > 1000000 { 8173 + return xerrors.Errorf("Value in field v was too long") 8174 + } 8175 + 8176 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil { 8177 + return err 8178 + } 8179 + if _, err := cw.WriteString(string(v)); err != nil { 8180 + return err 8181 + } 8182 + 8183 + } 8184 + } 8105 8185 return nil 8106 8186 } 8107 8187 ··· 8130 8210 8131 8211 n := extra 8132 8212 8133 - nameBuf := make([]byte, 9) 8213 + nameBuf := make([]byte, 10) 8134 8214 for i := uint64(0); i < n; i++ { 8135 8215 nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 8136 8216 if err != nil { ··· 8240 8320 } 8241 8321 8242 8322 } 8323 + // t.Mentions ([]string) (slice) 8324 + case "mentions": 8325 + 8326 + maj, extra, err = cr.ReadHeader() 8327 + if err != nil { 8328 + return err 8329 + } 8330 + 8331 + if extra > 8192 { 8332 + return fmt.Errorf("t.Mentions: array too large (%d)", extra) 8333 + } 8334 + 8335 + if maj != cbg.MajArray { 8336 + return fmt.Errorf("expected cbor array") 8337 + } 8338 + 8339 + if extra > 0 { 8340 + t.Mentions = make([]string, extra) 8341 + } 8342 + 8343 + for i := 0; i < int(extra); i++ { 8344 + { 8345 + var maj byte 8346 + var extra uint64 8347 + var err error 8348 + _ = maj 8349 + _ = extra 8350 + _ = err 8351 + 8352 + { 8353 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 8354 + if err != nil { 8355 + return err 8356 + } 8357 + 8358 + t.Mentions[i] = string(sval) 8359 + } 8360 + 8361 + } 8362 + } 8243 8363 // t.CreatedAt (string) (string) 8244 8364 case "createdAt": 8245 8365 ··· 8250 8370 8251 8371 8252 8372 t.CreatedAt = string(sval) 8373 + } 8374 + // t.References ([]string) (slice) 8375 + case "references": 8376 + 8377 + maj, extra, err = cr.ReadHeader() 8378 + if err != nil { 8379 + return err 8380 + } 8381 + 8382 + if extra > 8192 { 8383 + return fmt.Errorf("t.References: array too large (%d)", extra) 8384 + } 8385 + 8386 + if maj != cbg.MajArray { 8387 + return fmt.Errorf("expected cbor array") 8388 + } 8389 + 8390 + if extra > 0 { 8391 + t.References = make([]string, extra) 8392 + } 8393 + 8394 + for i := 0; i < int(extra); i++ { 8395 + { 8396 + var maj byte 8397 + var extra uint64 8398 + var err error 8399 + _ = maj 8400 + _ = extra 8401 + _ = err 8402 + 8403 + { 8404 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 8405 + if err != nil { 8406 + return err 8407 + } 8408 + 8409 + t.References[i] = string(sval) 8410 + } 8411 + 8412 + } 8253 8413 } 8254 8414 8255 8415 default:
api/tangled/issuecomment.go

This file has not been changed.

api/tangled/pullcomment.go

This file has not been changed.

api/tangled/repoissue.go

This file has not been changed.

appview/db/db.go

This file has not been changed.

appview/db/issues.go

This file has not been changed.

appview/db/pulls.go

This file has not been changed.

appview/db/reference.go

This file has not been changed.

appview/ingester.go

This file has not been changed.

appview/issues/issues.go

This file has not been changed.

appview/models/issue.go

This file has not been changed.

appview/models/pull.go

This file has not been changed.

appview/pulls/pulls.go

This file has not been changed.

appview/refresolver/resolver.go

This file has not been changed.

lexicons/issue/comment.json

This file has not been changed.

lexicons/issue/issue.json

This file has not been changed.

lexicons/pulls/comment.json

This file has not been changed.

+2
api/tangled/repopull.go
··· 20 20 LexiconTypeID string `json:"$type,const=sh.tangled.repo.pull" cborgen:"$type,const=sh.tangled.repo.pull"` 21 21 Body *string `json:"body,omitempty" cborgen:"body,omitempty"` 22 22 CreatedAt string `json:"createdAt" cborgen:"createdAt"` 23 + Mentions []string `json:"mentions,omitempty" cborgen:"mentions,omitempty"` 23 24 Patch string `json:"patch" cborgen:"patch"` 25 + References []string `json:"references,omitempty" cborgen:"references,omitempty"` 24 26 Source *RepoPull_Source `json:"source,omitempty" cborgen:"source,omitempty"` 25 27 Target *RepoPull_Target `json:"target" cborgen:"target"` 26 28 Title string `json:"title" cborgen:"title"`
+14
lexicons/pulls/pull.json
··· 36 36 "createdAt": { 37 37 "type": "string", 38 38 "format": "datetime" 39 + }, 40 + "mentions": { 41 + "type": "array", 42 + "items": { 43 + "type": "string", 44 + "format": "did" 45 + } 46 + }, 47 + "references": { 48 + "type": "array", 49 + "items": { 50 + "type": "string", 51 + "format": "at-uri" 52 + } 39 53 } 40 54 } 41 55 }

History

13 rounds 0 comments
sign up or login to add to the discussion
1 commit
expand
appview,lexicons: atprotate the mentions & references
3/3 failed
expand
expand 0 comments
pull request successfully merged
1 commit
expand
appview,lexicons: atprotate the mentions & references
1/3 failed, 2/3 running
expand
expand 0 comments
1 commit
expand
appview,lexicons: atprotate the mentions & references
3/3 success
expand
expand 0 comments
1 commit
expand
appview,lexicons: atprotate the mentions & references
3/3 success
expand
expand 0 comments
1 commit
expand
appview,lexicons: atprotate the mentions & references
3/3 success
expand
expand 0 comments
1 commit
expand
appview,lexicons: atprotate the mentions & references
3/3 success
expand
expand 0 comments
1 commit
expand
appview,lexicons: atprotate the mentions & references
3/3 success
expand
expand 0 comments
1 commit
expand
appview,lexicons: atprotate the mentions & references
3/3 success
expand
expand 0 comments
1 commit
expand
appview,lexicons: atprotate the mentions & references
3/3 success
expand
expand 0 comments
1 commit
expand
appview,lexicons: atprotate the mentions & references
3/3 failed
expand
expand 0 comments
1 commit
expand
appview,lexicons: atprotate the mentions & references
1/3 failed, 2/3 timeout
expand
expand 0 comments
1 commit
expand
appview,lexicons: atprotate the mentions & references
1/3 failed, 2/3 timeout
expand
expand 0 comments
1 commit
expand
appview,lexicons: atprotate the mentions & references
3/3 success
expand
expand 0 comments