github::ActivityMonitor method sync_from_github (public)
<instance of github::ActivityMonitor> sync_from_github
Defined in packages/xowiki/tcl/github-activity-monitor-procs.tcl
Sync recent GitHub events. Treat PushEvents as triggers for shallow repo/branch backfills, rather than inserting only payload.head.
- Testcases:
- No testcase defined.
Source code: ns_log Notice "GitHub: refresh_activity start" set new_events [:fetch_new_events] if {[llength $new_events] == 0} { ns_log Notice "GitHub: no new events" return } # # fetch_new_events returns oldest-first in your current implementation. # The newest event is therefore the last element. # set newest_event_id [dict get [lindex $new_events end] id] # # Collect distinct repo/branch pairs touched by PushEvents. # array set seen {} set backfill_jobs {} foreach ev $new_events { if {[dict get $ev type] ne "PushEvent"} { continue } set repo [dict get $ev repo name] set ref [dict get $ev payload ref] # # Only branch pushes. Skip tags and other refs. # if {![string match "refs/heads/*" $ref]} { ns_log Notice "GitHub: skipping non-branch push ref $ref in $repo" continue } set branch [string range $ref [string length "refs/heads/"] end] set key "$repo\t$branch" if {![info exists seen($key)]} { set seen($key) 1 lappend backfill_jobs [list $repo $branch] } } ns_log Notice "GitHub: found [llength $backfill_jobs] repo/branch backfill job(s)" foreach job $backfill_jobs { lassign $job repo branch ns_log Notice "GitHub: shallow backfill for $repo branch $branch" if {[catch { :backfill_repo_history -repo $repo -branch $branch -start_page 1 -max_pages 2 } errorMsg]} { ns_log Error "GitHub: shallow backfill failed for $repo $branch: $errorMsg" # # Do not abort the whole sync. Another run can recover. # continue } } # # Update event checkpoint after we processed the batch. # Since backfill is idempotent via ON CONFLICT, it is OK if a few # commits are recovered by the next scheduled run or manual backfill. # :set_state last_org_event_id $newest_event_id ns_log Notice "GitHub: refresh_activity done; processed [llength $new_events] event(s), [llength $backfill_jobs] backfill job(s)"XQL Not present: Generic, PostgreSQL, Oracle
![[i]](/resources/acs-subsite/ZoomIn16.gif)