Better groups

未关闭
#1 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
48/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
javascript
领域
api

调研方向

首先阅读 protoquery 中针对 GROUPSTART 和 GROUPEND 消息描述的查询行为。跟踪 10:bytes、10.1:var 和 10.5:string 等查询的解释方式;当嵌套的 repeated 字段可以直接查询,而无需先提取并重新解析每个子消息时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

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:

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:

{
  "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:

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.

主要语言
JavaScript
星标
1
派生
1
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。