33import dlt
44import pendulum
55
6- from .helpers import _normalize_issue , _normalize_team , _paginate
6+ from .helpers import _paginate , normalize_dictionaries
77
88
99def _get_date_range (updated_at , start_date ):
@@ -99,7 +99,25 @@ def _get_date_range(updated_at, start_date):
9999 }
100100}
101101"""
102-
102+ WORKFLOW_STATES_QUERY = """
103+ query WorkflowStates($cursor: String) {
104+ workflowStates(first: 50, after: $cursor) {
105+ nodes {
106+ archivedAt
107+ color
108+ createdAt
109+ id
110+ inheritedFrom { id }
111+ name
112+ position
113+ team { id }
114+ type
115+ updatedAt
116+ }
117+ pageInfo { hasNextPage endCursor }
118+ }
119+ }
120+ """
103121
104122@dlt .source (name = "linear" , max_table_nesting = 0 )
105123def linear_source (
@@ -122,7 +140,7 @@ def issues(
122140 for item in _paginate (api_key , ISSUES_QUERY , "issues" ):
123141 if pendulum .parse (item ["updatedAt" ]) >= current_start_date :
124142 if pendulum .parse (item ["updatedAt" ]) <= current_end_date :
125- yield _normalize_issue (item )
143+ yield normalize_dictionaries (item )
126144
127145 @dlt .resource (name = "projects" , primary_key = "id" , write_disposition = "merge" )
128146 def projects (
@@ -139,7 +157,7 @@ def projects(
139157 for item in _paginate (api_key , PROJECTS_QUERY , "projects" ):
140158 if pendulum .parse (item ["updatedAt" ]) >= current_start_date :
141159 if pendulum .parse (item ["updatedAt" ]) <= current_end_date :
142- yield item
160+ yield normalize_dictionaries ( item )
143161
144162 @dlt .resource (name = "teams" , primary_key = "id" , write_disposition = "merge" )
145163 def teams (
@@ -158,7 +176,7 @@ def teams(
158176 for item in _paginate (api_key , TEAMS_QUERY , "teams" ):
159177 if pendulum .parse (item ["updatedAt" ]) >= current_start_date :
160178 if pendulum .parse (item ["updatedAt" ]) <= current_end_date :
161- yield _normalize_team (item )
179+ yield normalize_dictionaries (item )
162180
163181 @dlt .resource (name = "users" , primary_key = "id" , write_disposition = "merge" )
164182 def users (
@@ -175,6 +193,23 @@ def users(
175193 for item in _paginate (api_key , USERS_QUERY , "users" ):
176194 if pendulum .parse (item ["updatedAt" ]) >= current_start_date :
177195 if pendulum .parse (item ["updatedAt" ]) <= current_end_date :
178- yield item
196+ yield normalize_dictionaries (item )
197+
198+ @dlt .resource (name = "workflow_states" , primary_key = "id" , write_disposition = "merge" )
199+ def workflow_states (
200+ updated_at : dlt .sources .incremental [str ] = dlt .sources .incremental (
201+ "updatedAt" ,
202+ initial_value = start_date .isoformat (),
203+ end_value = end_date .isoformat () if end_date else None ,
204+ range_start = "closed" ,
205+ range_end = "closed" ,
206+ ),
207+ ) -> Iterator [Dict [str , Any ]]:
208+ current_start_date , current_end_date = _get_date_range (updated_at , start_date )
209+
210+ for item in _paginate (api_key , WORKFLOW_STATES_QUERY , "workflowStates" ):
211+ if pendulum .parse (item ["updatedAt" ]) >= current_start_date :
212+ if pendulum .parse (item ["updatedAt" ]) <= current_end_date :
213+ yield normalize_dictionaries (item )
214+ return [issues , projects , teams , users , workflow_states ]
179215
180- return issues , projects , teams , users
0 commit comments