Skip to content

Commit

Permalink
add PR description
Browse files Browse the repository at this point in the history
Signed-off-by: Sergey Chvalyuk <grubberr@gmail.com>
  • Loading branch information
grubberr committed Jun 22, 2022
1 parent 41c7254 commit edb3bbf
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ def convert_cursor_value(self, value):

class WorkflowRuns(SemiIncrementalMixin, GithubStream):
"""
Get all workflows of a GitHub repository
Get all workflow runs for a GitHub repository
API documentation: https://docs.github.com/en/rest/actions/workflow-runs#list-workflow-runs-for-a-repository
"""

Expand All @@ -1131,6 +1131,12 @@ def read_records(
stream_slice: Mapping[str, Any] = None,
stream_state: Mapping[str, Any] = None,
) -> Iterable[Mapping[str, Any]]:
# Records in the workflows_runs stream are naturally descending sorted by `created_at` field.
# On first sight this is not big deal because cursor_field is `updated_at`.
# But we still can use `created_at` as a breakpoint because after 30 days period
# https://docs.github.com/en/actions/managing-workflow-runs/re-running-workflows-and-jobs
# workflows_runs records cannot be updated. It means if we initially fully synced stream on subsequent incremental sync we need
# only to look behind on 30 days to find all records which were updated.
start_point = self.get_starting_point(stream_state=stream_state, stream_slice=stream_slice)
break_point = (pendulum.parse(start_point) - pendulum.duration(days=self.re_run_period)).to_iso8601_string()
for record in super(SemiIncrementalMixin, self).read_records(
Expand Down

0 comments on commit edb3bbf

Please sign in to comment.