Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Google People API-按更新时间排序未按预期工作_Java_Google People Api - Fatal编程技术网

Java Google People API-按更新时间排序未按预期工作

Java Google People API-按更新时间排序未按预期工作,java,google-people-api,Java,Google People Api,我已经成功地使用Google People API来检索我的Google联系人,但我发现API在上次更新时排序不正确(例如,使用setSortOrder(“上次修改”)。此外,在查看此代码的输出时,发现有一个有趣的模式: private static void getLastModified()抛出GeneralSecurityException,IOException{ PeopleService服务=getService(); ListConnectionsResponse响应= servi

我已经成功地使用Google People API来检索我的Google联系人,但我发现API在上次更新时排序不正确(例如,使用
setSortOrder(“上次修改”)。此外,在查看此代码的输出时,发现有一个有趣的模式:

private static void getLastModified()抛出GeneralSecurityException,IOException{
PeopleService服务=getService();
ListConnectionsResponse响应=
service.people().connections().list(“people/me”)
.setPageSize(30)
.setPersonFields(“名称、元数据”)
.setSortOrder(“上次修改的顺序”)
.execute();
for(Person:response.getConnections()){
//System.out.println(person.getNames());
对于(源s:person.getMetadata().getSources()){
如果(s.getType().equals(“CONTACT”)){
System.out.println(s.getUpdateTime());
}
}
}
}
最后修改的结果按降序排序:

2020-05-07T19:27:27.469Z    <-- ok (which means this contact is for sure modified by me on the given day)
2020-05-07T19:27:03.418Z    <-- ok
2020-05-07T19:26:20.219Z    <-- ok
2020-05-07T19:25:39.684Z    <-- ok
2020-05-07T19:25:13.823Z    <-- ok
2020-05-07T19:24:13.732Z    <-- ok
2020-05-07T13:04:47.637Z    <-- ok
2020-04-12T17:18:31.714156Z <-- NOT ok (contact is probably modified by me on that day, but why is it positioned incorrectly?)
2020-04-15T20:49:28.733412Z <-- NOT ok
2020-05-06T17:20:19.840Z    <-- ok
2020-05-06T17:18:22.134Z    <-- ok
2020-05-06T17:17:33.185Z    <-- ok
2020-05-06T16:41:00.368Z    <-- ok
2020-05-06T16:40:50.119Z    <-- ok
2020-05-06T15:02:49.218Z    <-- ok
2020-05-06T14:29:27.963Z    <-- ok
2020-05-06T14:28:40.890Z    <-- ok
2020-05-06T14:26:56.322Z    <-- ok
2020-05-06T14:26:04.658Z    <-- ok
2020-05-06T14:25:17.177Z    <-- ok
2020-05-06T14:24:12.801Z    <-- ok
2020-05-06T14:23:13.461Z    <-- ok
2020-05-06T14:22:04.888Z    <-- ok
2020-04-12T19:26:25.392253Z <-- NOT ok
2020-05-06T12:05:32.209Z    <-- ok
2020-05-06T11:57:11.286Z    <-- ok
2018-08-15T13:49:04.254001Z <-- NOT ok
2020-04-12T15:10:27.421184Z <-- NOT ok
2020-05-05T17:51:52.572Z    <-- ok
2020-05-05T17:50:43.904Z    <-- ok

2020-05-07T19:27:27.469Z感谢@Raserhin建议将该问题发布到谷歌问题跟踪器-我这样做了,得到了答案,并且能够回答我自己的问题

关于问题的第一部分:

有人能再解释一下吗

当时,我得到了一份详细的解释,证明了我的猜测:

我们的后端服务根据给定合并人员中包含的联系人和个人资料中最后修改的时间戳进行排序。然而,当我们的人员服务传递数据时,它只公开联系人的时间戳,而不公开个人资料的时间戳。是的,当排序键字段未完全返回时,它不是一个信息性API设计。但是,如果我们想公开配置文件更改时间戳,我需要在团队和隐私审查中运行这个想法

问题的第二部分:

如何强制API忽略
概要文件
元数据源并仅根据我的修改时间戳进行排序


API目前显然无法做到这一点,因此需要使用这种排序的每个开发人员都必须考虑到所描述的行为,并选择接受它或创建一个解决方案(例如,检索所有联系人并在不太昂贵的情况下对其进行排序)。

据我所知,这是预期的行为,重要的是最后一次修改此人。如果您仍然认为这是一个bug,您可以继续并尝试将其发布到中。关于你的问题,你能把你所有的联系人都放在内存中吗?我不知道你会如何自己排序,否则,你会受到谷歌提供信息的方式的限制。@Raserhin是的,我可以将我的所有联系人放在内存或数据库中(谷歌提供了一种通过提交上一个请求中收到的pageToken来检索后续页面的方法)我同意上面所描述的一切可能都是预期的行为,但是他们应该通过API提供正确的最后修改时间。那么,在检索所有联系人之后,您可以对列表进行排序吗?我知道你有所有的信息来整理它。