I'm going to look into go-oasis to see if they handled this
@erin asked about how to get votes for a post for their client (https://matrix.to/#/!SrcUDxvxhmyHlrHzgd:matrix.org/$jlkhaDPcOdrs3aPMWcCcghwgqWVcQy3FJS_Yzpwq0yo?via=matrix.org&via=chat.is-cute.ml)
I'm going to look into go-oasis to see if they handled this
ok I've confirmed that in goasis (a fork of oasis that cryptix made which uses go-sbot as a backend) they use ssb.backlinks to get votes for a post
https://git.sr.ht/~cryptix/ssb-oasis/tree/master/item/src/models.js#L398
however, I'm not sure yet what backlinks is exactly, whether its filtering built in javascript that we need to remake in rust, or if there go-sbot calls that can help with that
I think it could be a good question to ask the planetary devs about as well
I posted what I found in the #golgi[ matrix channel ](https://matrix.to/#/!SrcUDxvxhmyHlrHzgd:matrix.org/$_oLPeNtc-KZS2g9kxAZZc8JdTarCXr4gearN6iBi8TI?via=matrix.org&via=chat.is-cute.ml)
```
ok I've confirmed that in goasis (a fork of oasis that cryptix made which uses go-sbot as a backend) they use ssb.backlinks to get votes for a post
https://git.sr.ht/~cryptix/ssb-oasis/tree/master/item/src/models.js#L398
however, I'm not sure yet what backlinks is exactly, whether its filtering built in javascript that we need to remake in rust, or if there go-sbot calls that can help with that
```
I think it could be a good question to ask the planetary devs about as well
Nice detective work. I think that ssb-backlinks creates a database index of all messages which mention / reference another message. This includes votes, since a vote message mentions the message being voted on. It's then relatively fast to query these messages because they've already been indexed (with the index having been stored in the flume database).
+1 very interested to hear how the Planetary devs are doing this.
@notplants
Nice detective work. I _think_ that ssb-backlinks creates a database index of all messages which mention / reference another message. This includes votes, since a vote message mentions the message being voted on. It's then relatively fast to query these messages because they've already been indexed (with the index having been stored in the flume database).
+1 very interested to hear how the Planetary devs are doing this.
afaiu Planetary folks are just taking the entire append-only log and piling it into a sqlite database and then the front-end is using that to put together queries and such.
I've opened up https://github.com/ssbc/go-ssb/issues/200 to try to track down how to get only votes on a post. tangles.thread gets replies. We're missing something, hopefully I'll manage to figure it out.
afaiu Planetary folks are just taking the entire append-only log and piling it into a sqlite database and then the front-end is using that to put together queries and such.
I've opened up https://github.com/ssbc/go-ssb/issues/200 to try to track down how to get only votes on a post. `tangles.thread` gets replies. We're missing something, hopefully I'll manage to figure it out.
I currently have tangles.thread working on dev branches of kuska + golgi. I'm making sure all the optional args work as expected and then I'll get that all merged.
My workaround idea for getting votes on a post would be:
Check the root field in the message (to get the key of the root msg of the thread)
Call tangles.thread with the root msg key (returns a stream of messages)
Filter posts of type vote which reference the post of interest
Tally votes made by each author to determine vote state (even or odd)
If an easier way comes along, awesome!
I currently have `tangles.thread` working on dev branches of `kuska` + `golgi`. I'm making sure all the optional args work as expected and then I'll get that all merged.
My workaround idea for getting votes on a post would be:
1. Check the `root` field in the message (to get the key of the root msg of the thread)
2. Call `tangles.thread` with the root msg key (returns a stream of messages)
3. Filter posts of type `vote` which reference the post of interest
4. Tally votes made by each author to determine vote state (even or odd)
If an easier way comes along, awesome!
Filter posts of type vote which reference the post of interest
From my testing, I see that no type=vote posts come back in the out of sbotcli replies (uses tangles.threads internally)? Lemme know if you see it tho, I might be missing it in the blob-of-JSON-return 🙃
Would be great to solve this as I need this functionality too.
> 3. Filter posts of type vote which reference the post of interest
From my testing, I see that no `type=vote` posts come back in the out of `sbotcli replies` (uses `tangles.threads` internally)? Lemme know if you see it tho, I might be missing it in the blob-of-JSON-return 🙃
Would be great to solve this as I need this functionality too.
Only two...should be lots more. Not sure if it's just a case of the other vote messages not having replicated yet?
Hmm I am seeing votes in some cases but not others (and not all the votes).
Here's an example:
```shell
sbotcli replies "%vY53ethgEG1tNsKqmLm6isNSbsu+jwMf/UNGMfUiLm0=.sha256" | grep '"type":"vote"'
```
Output:
```json
{"previous":null,"author":"@DIoOBMaI1f0mJg+5tUzZ7vgzCeeHh8+zGta4pOjc+k0=.ed25519","sequence":1987,"timestamp":1668483452000,"hash":"","signature":"","content":{"type":"vote","text":"","root":"%vY53ethgEG1tNsKqmLm6isNSbsu+jwMf/UNGMfUiLm0=.sha256","branch":["%vY53ethgEG1tNsKqmLm6isNSbsu+jwMf/UNGMfUiLm0=.sha256"]}}
{"previous":null,"author":"@DIoOBMaI1f0mJg+5tUzZ7vgzCeeHh8+zGta4pOjc+k0=.ed25519","sequence":1990,"timestamp":1668645471000,"hash":"","signature":"","content":{"type":"vote","text":"","root":"%vY53ethgEG1tNsKqmLm6isNSbsu+jwMf/UNGMfUiLm0=.sha256","branch":["%Jm7Bx6PrtDZPFXSsQKr1p7Rrm7HeWCP7mOslKAUh+UY=.sha256","%LLB1UxYAUM1d79uOrV/79NmlOSISR/crRZPG0VCCHQw=.sha256"]}}
```
Only two...should be lots more. Not sure if it's just a case of the other vote messages not having replicated yet?
Here's another one that yields a vote, but in general I'm seeing far fewer than I would expect.
```shell
sbotcli replies "%Pnas64BJ60qbHF34BvsHiXYvMRj7CyKq8nsOlDCsWqA=.sha256" | grep '"type":"vote"'
```
Output:
```json
{"previous":null,"author":"@yUrNCh6XowOLtszmSlBCC0AziDdm8m4X//bcvkz/4Yg=.ed25519","sequence":137,"timestamp":1651879877000,"hash":"","signature":"","content":{"type":"vote","text":"","root":"%Pnas64BJ60qbHF34BvsHiXYvMRj7CyKq8nsOlDCsWqA=.sha256","branch":["%Pnas64BJ60qbHF34BvsHiXYvMRj7CyKq8nsOlDCsWqA=.sha256"]}}
```
Right, I think https://github.com/ssbc/go-ssb/issues/251 is the cause for the lack of vote responses. TLDR; go-sbot is not correctly indexing all the messages. Working on a fix.
Right, I think https://github.com/ssbc/go-ssb/issues/251 is the cause for the lack of vote responses. TLDR; `go-sbot` is not correctly indexing all the messages. Working on a fix.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
@erin asked about how to get votes for a post for their client (https://matrix.to/#/!SrcUDxvxhmyHlrHzgd:matrix.org/$jlkhaDPcOdrs3aPMWcCcghwgqWVcQy3FJS_Yzpwq0yo?via=matrix.org&via=chat.is-cute.ml)
I'm going to look into go-oasis to see if they handled this
I'm intrigued to hear how / if go-oasis did this.
I posted what I found in the #golgi matrix channel
I think it could be a good question to ask the planetary devs about as well
@notplants
Nice detective work. I think that ssb-backlinks creates a database index of all messages which mention / reference another message. This includes votes, since a vote message mentions the message being voted on. It's then relatively fast to query these messages because they've already been indexed (with the index having been stored in the flume database).
+1 very interested to hear how the Planetary devs are doing this.
afaiu Planetary folks are just taking the entire append-only log and piling it into a sqlite database and then the front-end is using that to put together queries and such.
I've opened up https://github.com/ssbc/go-ssb/issues/200 to try to track down how to get only votes on a post.
tangles.threadgets replies. We're missing something, hopefully I'll manage to figure it out.I currently have
tangles.threadworking on dev branches ofkuska+golgi. I'm making sure all the optional args work as expected and then I'll get that all merged.My workaround idea for getting votes on a post would be:
rootfield in the message (to get the key of the root msg of the thread)tangles.threadwith the root msg key (returns a stream of messages)votewhich reference the post of interestIf an easier way comes along, awesome!
From my testing, I see that no
type=voteposts come back in the out ofsbotcli replies(usestangles.threadsinternally)? Lemme know if you see it tho, I might be missing it in the blob-of-JSON-return 🙃Would be great to solve this as I need this functionality too.
Hmm I am seeing votes in some cases but not others (and not all the votes).
Here's an example:
Output:
Only two...should be lots more. Not sure if it's just a case of the other vote messages not having replicated yet?
Here's another one that yields a vote, but in general I'm seeing far fewer than I would expect.
Output:
Right, I think https://github.com/ssbc/go-ssb/issues/251 is the cause for the lack of vote responses. TLDR;
go-sbotis not correctly indexing all the messages. Working on a fix.