Skip to content

Comments

feat: user_id_list在config.json支持混合的模式#268

Closed
eggachecat wants to merge 2 commits intodataabc:masterfrom
eggachecat:master
Closed

feat: user_id_list在config.json支持混合的模式#268
eggachecat wants to merge 2 commits intodataabc:masterfrom
eggachecat:master

Conversation

@eggachecat
Copy link
Contributor

可以支持如下的配置

{
    "user_id_list": ["1729370543", {
        "id": "1669879400",
        "since_date": "2020-11-01 18:15"
    }],
}

这样使得程序的调用的时候会更灵活一点

user_id_list = FLAGS.u.split(',')
if isinstance(user_id_list, list):
user_id_list = list(set(user_id_list))
user_id_list = list(user_id_list)
Copy link
Owner

@dataabc dataabc Dec 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢贡献代码,非常实用的修改。还有一些地方需要改,不知道想的是否正确。

这一句是否应该去掉或修改。原来的语句目的是去重,加入dict后,原方式就不能用了。当前语句下,user_id_list本就是list形式,再转一次list是否有必要。我的建议是删去此句,或者改成可以去重的形式。这是我的想法,不知道是否考虑周全

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dataabc wow是的!不确定去重需要考虑吗?这部分放在 调用方 更好?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

所以这句可以去掉,也可以改成去重的。因为id是用户输的,不确定是不是有重复的。去重是一定会添加的,如果你不想添加,删掉就可以,后面我自己弄就行。如果你行有余力,当然加上去重更好啦。

Copy link
Contributor Author

@eggachecat eggachecat Dec 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dataabc 我PR了新的一种方案:
判断如果是以前的情况(不含dict的),则使用原本的去重
如果是新的(含有dict类型)则使用这个feat
不知道你觉得如何?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我发现我写了一行
「user_id_list = user_id_list」
我决定重新提交一次...

@dataabc
Copy link
Owner

dataabc commented Dec 9, 2020

上面的修改很好,不过有个缺点,就是如果

{
    "user_id_list": ["1729370543", "1729370543",{
        "id": "1669879400",
        "since_date": "2020-11-01 18:15"
    }],
}

就没法去重了,可以这样

temp = []
for i in user_id_list:
    if i not in temp:
        temp.append(i)

temp就是没有重复的结果

@eggachecat
Copy link
Contributor Author

@dataabc
我明白你的意思了
我会把他们分开去重再拼在一起~

@dataabc
Copy link
Owner

dataabc commented Dec 9, 2020

感谢。

其实没必要重开pull request。只要在自己项目下修改,pull request会自动同步的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants