It adds a possibility to record any label-related actions into label taxonomy.
Context:
There is a cron job which is fetching repo & user events (like PR/issue open/closed, comment added, commits added etc) and create relevant GitHub Event custom post type. In case of Issue/PR event - it also creates GitHub Issue CPT, where a bunch of different data (together with a list of labels) is stored as taxonomies.
The problem is that used API endpoints return only a limited range of Issue/PR event types (only created & closed), which means it not possible to track any label changes.
There is /repos/repo_name/issues/events endpoint which returns all the issue related events, but its schema differs from the endpoints mentioned above.
How things work:
Every time when cron job is triggered - this plugin will fetch /repos/repo_name/issues/events to get all the issue/PR related events (after other events were processed). For every labeled or unlabeled event it updates Issue Event label taxonomy (ghactivity_issues_labels) by adding term metadata such as: status, labeled, unlabeled. Label taxonomies are not unique, so to be able to distinguish one issue labels metadata from another I come up with this structure:
Confirm that Issue Events now includes your new created issue. Figure out post_id of your issue (follow/hover post name to see url, it will include a post_id: http://cld.wthms.co/i5XoU7)
select tt.term_id, t.name, t.slug, tm.meta_key, tm.meta_value from $term_relationships as tr
inner join $term_taxonomy as tt on tr.term_taxonomy_id = tt.term_taxonomy_id
inner join $terms as t on tt.term_id=t.term_id
inner join $termmeta as tm on tm.term_id=t.term_id
where tr.object_id=YOUR_POST_ID
and tt.taxonomy='ghactivity_issues_labels'
Update labels (add new/remove old) in your issue. re-trigger cron job, re-run SQL query. results should reflect changes you made.
This PR adds underlying functionality for https://github.com/Automattic/ghactivity/issues/3
It adds a possibility to record any label-related actions into label taxonomy.
Context:
There is a cron job which is fetching
repo
&user
events (like PR/issue open/closed, comment added, commits added etc) and create relevantGitHub Event
custom post type. In case of Issue/PR event - it also createsGitHub Issue
CPT, where a bunch of different data (together with a list of labels) is stored as taxonomies. The problem is that used API endpoints return only a limited range of Issue/PR event types (onlycreated
&closed
), which means it not possible to track any label changes.There is
/repos/repo_name/issues/events
endpoint which returns all the issue related events, but its schema differs from the endpoints mentioned above.How things work:
Every time when cron job is triggered - this plugin will fetch
/repos/repo_name/issues/events
to get all the issue/PR related events (after other events were processed). For everylabeled
orunlabeled
event it updatesIssue Event
label taxonomy (ghactivity_issues_labels
) by adding term metadata such as:status
,labeled
,unlabeled
. Label taxonomies are not unique, so to be able to distinguish one issue labels metadata from another I come up with this structure:So now, any label which is used in multiple issues/repos will have metadata for every specific issue
Also, this PR includes some refactoring and nesting simplifications.
To test:
Issue Events
here: https://brbrr.wpsandbox.me/wp-admin/edit.php?post_type=ghactivity_issueghactivity_publish
cron job hereIssue Events
now includes your new created issue. Figure out post_id of your issue (follow/hover post name to see url, it will include a post_id: http://cld.wthms.co/i5XoU7)cron job may take 1-2 min to finish.