bbaumgartner / jtoggl

Automatically exported from code.google.com/p/jtoggl
16 stars 21 forks source link

New JToggl (with v8 support) doesn't print project... #5

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. JToggl toggl = new JToggl(myAPIToken, "api_token");
   List<TimeEntry> entries = toggl.getTimeEntries();
   System.out.println(entries);
2. Look at the result

What is the expected output? What do you see instead?

I get the list but the project is always printed as null:
[TimeEntry{id=88245264, description=Misc... Reinstalling desktop etc., 
project=null, start=Mon Aug 26 06:30:00 CEST 2013, stop=Mon Aug 26 14:48:35 
CEST 2013, duration=29862, billable=false, workspace=null, tag_names=[], 
duronly=false},...

Calling getProject() returns null as well so it is probably not just a bug in 
toString().
Workspace probably shouldn't be null either but I don't care about that.

If I call TimeEntry.toJSONObject I get the following... So it looks like the 
project is actually there (assuming pid is a project id and wid is the 
workspace id)

{"tags":[""],"id":88245264,"stop":"2013-08-26T14:48:35+02:00","duration":29862,"
wid":247298,"start":"2013-08-26T06:30:00+02:00","description":"Misc... 
Reinstalling desktop etc.","pid":1761854,"duronly":false,"billable":false}

Unfortunately, I don't have time to track it down my self right now. I was just 
playing around. Shouldn't be hard to find though.. Thanks.

Original issue reported on code.google.com by fredr...@gmail.com on 3 Sep 2013 at 7:54

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
If anyone else runs into this, the following seems to be a work-around:

List<Project> projectList = toggl.getProjects();
Map<Long, Project> projects = new HashMap<Long, Project>();
for(Project project : projectList) {
    projects.put(project.getId(), project);
}
List<TimeEntry> entries = toggl.getTimeEntries();
for(TimeEntry e : entries) {
    e.setProject(projects.get(e.getPid()));
    System.out.println(e);
}

Original comment by fredr...@gmail.com on 3 Sep 2013 at 8:09

GoogleCodeExporter commented 9 years ago
Thanks for the bug report. There is not much we can do about this on our side, 
the call to https://www.toggl.com/api/v8/time_entries only returns the wid 
(workspace id) and pid (project id) for each entry and not the resolved 
workspace and project (I think in v6 that was different). Hence when calling 
getTimeEntries() pid/wid is set but project/workspace is null. To resolve the 
project/workspace your workaround is the new way to go.

I'm closing this as "works as specified", ok?

Original comment by hisduden...@comerge.net on 3 Oct 2013 at 8:40

GoogleCodeExporter commented 9 years ago
Sure. I have worked around it.

Original comment by fredr...@gmail.com on 3 Oct 2013 at 9:57