Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add internal kernel API /api/riff/getRiffCardsByBlockIDs #10535

Closed
IAliceBobI opened this issue Mar 7, 2024 · 12 comments
Closed

Add internal kernel API /api/riff/getRiffCardsByBlockIDs #10535

IAliceBobI opened this issue Mar 7, 2024 · 12 comments
Assignees
Milestone

Comments

@IAliceBobI
Copy link

IAliceBobI commented Mar 7, 2024

请求添加通过块id查找闪卡id的批量接口。

In what scenarios do you need this feature?

目前一些闪卡接口都是要求cardID。编辑器上操作的都是块。

目前的转换只能是,全量闪卡查出做缓存。

希望能有用块查card的接口,返回的实体类似 "/api/riff/getTreeRiffCards" 接口的。

@88250 88250 self-assigned this Mar 7, 2024
@88250
Copy link
Member

88250 commented Mar 7, 2024

“批量”指的是传入参数需要传入块 ID 列表?

@IAliceBobI
Copy link
Author

@88250 对,一次给多个块id。这样也能自己封装单个接口。

@88250 88250 changed the title 请求添加通过块id查找闪卡id的批量接口。 Add kernel API /api/riff/getRiffCardsByBlockIDs Mar 7, 2024
@88250 88250 added this to the 3.0.3 milestone Mar 7, 2024
@88250
Copy link
Member

88250 commented Mar 7, 2024

http://127.0.0.1:6806/api/riff/getRiffCardsByBlockIDs

参数:

{
    "blockIDs": ["20231226210349-s9iqv9m", "20231226222829-yre8r9z"],
    "page": 1,
    "pageSize": 20
}

返回:

{
    "code": 0,
    "msg": "",
    "data": {
        "blocks": [
            {
                "box": "20220407175815-lceq17w",
                "path": "/20231225220807-sj8uajj.sy",
                "hPath": "/闪卡测试",
                "id": "20231226210349-s9iqv9m",
                "rootID": "20231225220807-sj8uajj",
                "parentID": "20231225220807-sj8uajj",
                "name": "",
                "alias": "",
                "memo": "",
                "tag": "",
                "content": "1 20231226210349-s9iqv9m",
                "fcontent": "",
                "markdown": "1 20231226210349-s9iqv9m",
                "folded": false,
                "type": "NodeParagraph",
                "subType": "",
                "refText": "",
                "refs": null,
                "defID": "",
                "defPath": "",
                "ial": {
                    "custom-riff-decks": "20230218211946-2kw8jgx",
                    "id": "20231226210349-s9iqv9m",
                    "updated": "20240307202715"
                },
                "children": null,
                "depth": 0,
                "count": 0,
                "sort": 10,
                "created": "",
                "updated": "",
                "riffCardID": "20240118200836-c9iub5q",
                "riffCard": {
                    "due": "2024-03-05T00:12:09.8522284+08:00",
                    "reps": 1,
                    "lapses": 1,
                    "state": 1,
                    "lastReview": "2024-03-05T00:11:09.8522284+08:00"
                }
            },
            {
                "box": "20220407175815-lceq17w",
                "path": "/20231225220807-sj8uajj.sy",
                "hPath": "/闪卡测试",
                "id": "20231226222829-yre8r9z",
                "rootID": "20231225220807-sj8uajj",
                "parentID": "20231225220807-sj8uajj",
                "name": "",
                "alias": "",
                "memo": "",
                "tag": "",
                "content": "2 20231226222829-yre8r9z",
                "fcontent": "",
                "markdown": "2 20231226222829-yre8r9z",
                "folded": false,
                "type": "NodeParagraph",
                "subType": "",
                "refText": "",
                "refs": null,
                "defID": "",
                "defPath": "",
                "ial": {
                    "custom-riff-decks": "20230218211946-2kw8jgx",
                    "id": "20231226222829-yre8r9z",
                    "updated": "20240307202719"
                },
                "children": null,
                "depth": 0,
                "count": 0,
                "sort": 10,
                "created": "",
                "updated": "",
                "riffCardID": "20240118200836-qtt6zgc",
                "riffCard": {
                    "due": "2024-03-07T10:18:39.3465395+08:00",
                    "reps": 2,
                    "lapses": 1,
                    "state": 1,
                    "lastReview": "2024-03-07T10:13:39.3465395+08:00"
                }
            }
        ],
        "pageCount": 1,
        "total": 2
    }
}

@IAliceBobI
Copy link
Author

有可能一个块对多个卡吧? @88250

@88250
Copy link
Member

88250 commented Mar 7, 2024

不会的,目前的结构只可能一个块对应一张卡。

@IAliceBobI
Copy link
Author

IAliceBobI commented Mar 7, 2024

不会的,目前的结构只可能一个块对应一张卡。

我就喜欢这样。

为什么有:
"page": 1,
"pageSize": 20

不是给几个返回几个吗?

@88250
Copy link
Member

88250 commented Mar 7, 2024

有道理……稍后删了。

@IAliceBobI
Copy link
Author

IAliceBobI commented Mar 7, 2024

如果不存在的card,也返回一个 {"id": "20231226222829-yre8r9z"} 占位吧 @88250

@88250
Copy link
Member

88250 commented Mar 7, 2024

好的,修改以后:

参数:

{
    "blockIDs": ["20231226210349-s9iqv9m", "20231226222829-yre8r9z1"]
}

返回:

{
    "code": 0,
    "msg": "",
    "data": {
        "blocks": [
            {
                "box": "20220407175815-lceq17w",
                "path": "/20231225220807-sj8uajj.sy",
                "hPath": "/闪卡测试",
                "id": "20231226210349-s9iqv9m",
                "rootID": "20231225220807-sj8uajj",
                "parentID": "20231225220807-sj8uajj",
                "name": "",
                "alias": "",
                "memo": "",
                "tag": "",
                "content": "1 20231226210349-s9iqv9m",
                "fcontent": "",
                "markdown": "1 20231226210349-s9iqv9m",
                "folded": false,
                "type": "NodeParagraph",
                "subType": "",
                "refText": "",
                "refs": null,
                "defID": "",
                "defPath": "",
                "ial": {
                    "custom-riff-decks": "20230218211946-2kw8jgx",
                    "id": "20231226210349-s9iqv9m",
                    "updated": "20240307202715"
                },
                "children": null,
                "depth": 0,
                "count": 0,
                "sort": 10,
                "created": "",
                "updated": "",
                "riffCardID": "20240118200836-c9iub5q",
                "riffCard": {
                    "due": "2024-03-05T00:12:09.8522284+08:00",
                    "reps": 1,
                    "lapses": 1,
                    "state": 1,
                    "lastReview": "2024-03-05T00:11:09.8522284+08:00"
                }
            },
            {
                "box": "",
                "path": "",
                "hPath": "",
                "id": "20231226222829-1111111",
                "rootID": "",
                "parentID": "",
                "name": "",
                "alias": "",
                "memo": "",
                "tag": "",
                "content": "不存在符合条件的内容块",
                "fcontent": "",
                "markdown": "",
                "folded": false,
                "type": "",
                "subType": "",
                "refText": "",
                "refs": null,
                "defID": "",
                "defPath": "",
                "ial": null,
                "children": null,
                "depth": 0,
                "count": 0,
                "sort": 0,
                "created": "",
                "updated": "",
                "riffCardID": "",
                "riffCard": null
            },
            {
                "box": "20220407175815-lceq17w",
                "path": "/20231225220807-sj8uajj.sy",
                "hPath": "/闪卡测试",
                "id": "20231226222829-yre8r9z",
                "rootID": "20231225220807-sj8uajj",
                "parentID": "20231225220807-sj8uajj",
                "name": "",
                "alias": "",
                "memo": "",
                "tag": "",
                "content": "2 20231226222829-yre8r9z",
                "fcontent": "",
                "markdown": "2 20231226222829-yre8r9z",
                "folded": false,
                "type": "NodeParagraph",
                "subType": "",
                "refText": "",
                "refs": null,
                "defID": "",
                "defPath": "",
                "ial": {
                    "custom-riff-decks": "20230218211946-2kw8jgx",
                    "id": "20231226222829-yre8r9z",
                    "updated": "20240307202719"
                },
                "children": null,
                "depth": 0,
                "count": 0,
                "sort": 10,
                "created": "",
                "updated": "",
                "riffCardID": "20240118200836-qtt6zgc",
                "riffCard": {
                    "due": "2024-03-07T10:18:39.3465395+08:00",
                    "reps": 2,
                    "lapses": 1,
                    "state": 1,
                    "lastReview": "2024-03-07T10:13:39.3465395+08:00"
                }
            }
        ]
    }
}

@zxhd863943427
Copy link
Contributor

这个api可能是不稳定的,之后改进闪卡结构后,一个块对应多张闪卡和一张闪卡含有多个块都可能存在。

@IAliceBobI
Copy link
Author

IAliceBobI commented Mar 8, 2024

我也担心这个,实在不行就放入 "blocks" 里面,目前的结构不改。

{
    "code": 0,
    "msg": "",
    "data": {
        "blocks": [
            {

或者再多做一层。

{
    "code": 0,
    "msg": "",
    "data": [
        [ { card1 } { card2 } ] , [{ card3} ]
    ]
}

不过一个块对多个卡,操作起来就麻烦了。

@88250
Copy link
Member

88250 commented Mar 8, 2024

我觉得直接加到 blocks 就好了。另外, #10471 近期不会有时间做。

@88250 88250 changed the title Add kernel API /api/riff/getRiffCardsByBlockIDs Add internal kernel API /api/riff/getRiffCardsByBlockIDs Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants