Jump to content

Get project for Timelog.Context


instinct-vfx

Recommended Posts

Posted

Is there a shortcut to get that or do i need to manually do it? The context typically is a Task which should have project as an attribute. Context itself only has parent. Which may be Task or Project (or more?).

TL;DR; Is there a projection to performantly get project information on timelog iterating?

 

Cheers,

Thorsten

Posted

There is no such thing at the moment but there two potential ways of getting it in one query:

First the ugly one, brace yourself:

query = query('select context.parent.parent.parent from Timelog')

Alternatively you can use the link attribute on context:

query = query('select context.link from Timelog').all()

The first item in the link holds both project name and id.

Posted

Thanks Mattias,

 

while that works it is even slower in my use case it seems. Will have to doublecheck tough. What i am trying to do is get a custom attribute on the project level (to decide if a project as a whole is billable or not in this case).

What i am doing now is caching all projects and that attribute before getting the timelogs. Will need some more testing though. But a quite query for only 24 timelogs takes 10 seconds when evaluating for the custom attribute using this to test:

"context.parent.parent.parent.custom_attributes,"

Cheers,

Thorsten

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...