konsumer / konsumer/protoquery

Better groups

Open
#1 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1
Forks
1
PR merge metrics
No merged PRs in 30d

Description

I currently treat `GROUPSTART` messages like repeat messages, and pull all the bytes (up to and including `GROUPEND`) in protoquuery, so I can do this:

```js
const medias = query(appTree, '10:bytes').map(i => {
const t = getTree(i)
return {
type: query(t, '1:var').pop(),
url: query(t, '5:string').pop()
}
})
expect(medias.length).toEqual(10)
const icon = medias.find(m => m.type === 4).url
const screenshots = medias.filter(m => m.type === 1).map(m => m.url)
const videos = medias.filter(m => m.type === 3).map(m => m.url)
const videoThumbs = medias.filter(m => m.type === 13).map(m => m.url)
```

and get this:
```json
{
"icon": "https://play-lh.googleusercontent.com/qTt7JkhZ-U0kevENyTChyUijNUEctA3T5fh7cm8yzKUG0UAnMUgOMpG_9Ln7D24NbQ",
"screenshots": [
"https://play-lh.googleusercontent.com/m-S0SqOv428DZcm46NJlyv0pffYpfsNjWz6iyf9LVM1TCWbzWs3clWaugjfzXXnCTbY",
"https://play-lh.googleusercontent.com/WYyQPx2lhnCQYueR8q99NhIsxzJZX4NIHdlf0UxoPiwrHg1WlYGiFTy51F1aBZxaslE",
"https://play-lh.googleusercontent.com/ioUSrp79Yx_rZikYRI_XtK_mdP5kavcm9oWDWYrgVqXfS4bpW46y41lbGTQJT7tPn7ej",
"https://play-lh.googleusercontent.com/-8X4UtNoQm8k7cX7q5jT2fQmFFQbSJnreoxensBZQ7kuIs9d8FWwtyxM3QvqKd4SdBOA",
"https://play-lh.googleusercontent.com/_08ljE8yjFzGuroCP-6cemh2LIrQ_zptq5K4KLahsqAsCq5cjLSU-ghzkHhf2_0UZ9c",
"https://play-lh.googleusercontent.com/ofJcMSH2oJKzax3lscP-IJCZecGnkt7XWpt7L1J7KVhridE7wejHWqhrl4oV000sty1E"
],
"videos": [
"https://youtu.be/XT7YEb9_Muw"
],
"videoThumbs": [
"https://i.ytimg.com/vi/XT7YEb9_Muw/hqdefault.jpg"
]
}
```

It works, but it's a bit awkward to have to pull the sub-messages first (`10:bytes`) then parse each as a tree. I would rather it worked more like this:

```js
const mediaTypes = query(appTree, '10.1:var')
const mediaUrls = query(appTree, '10.5:string')
```

Where `10` is considered a "repeating message field" and 1/5 are fields of that, which you can pull as normal types.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading the query behavior described for GROUPSTART and GROUPEND messages in protoquery. Trace how queries such as `10:bytes`, `10.1:var`, and `10.5:string` are interpreted; done means nested repeated fields can be queried directly without first extracting and reparsing each sub-message.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.