github::ActivityMonitor method sync_from_github (public)

 <instance of github::ActivityMonitor[i]> sync_from_github

Defined in packages/xowiki/tcl/github-activity-monitor-procs.tcl

Sync events from github: fetch, summarize, insert

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
}

::xo::dc transaction {
    foreach ev $new_events {
        set summary [:summarize_push_event $ev]
        if {$summary eq ""} {
            continue
        }

        dict with summary {
            # Avoid duplicate insert if raced with another run
            xo::dc dml insert_activity {
                insert into github_activity (
                                             event_id, repo, branch, sha,
                                             author_name, author_login,
                                             commit_date, created_at,
                                             title, url,
                                             files_changed, additions, deletions,
                                             raw_payload
                                             ) values (
                                                       :event_id, :repo, :branch, :sha,
                                                       :author_name, :author_login,
                                                       :commit_date, :created_at,
                                                       :title, :url,
                                                       :files_changed, :additions, :deletions,
                                                       :raw_payload
                                                       )
                on conflict (repo, sha) do nothing
            }
        }
    }
}
ns_log Notice "GitHub: refresh_activity done; processed [llength $new_events] events"
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: