/
events-data.html
141 lines (121 loc) · 10.7 KB
/
events-data.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Timestamping with Events Data • ghtrackr</title>
<!-- jquery --><script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha384-nrOSfDHtoPMzJHjVTdCopGqIqeYETSXhZDFyniQ8ZHcVy08QesyHcnOUpMpqnmWq" crossorigin="anonymous"></script><!-- Bootstrap --><link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script><!-- Font Awesome icons --><link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous">
<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.7.1/clipboard.min.js" integrity="sha384-cV+rhyOuRHc9Ub/91rihWcGmMmCXDeksTtCihMupQHSsi8GIIRDG0ThDc3HGQFJ3" crossorigin="anonymous"></script><!-- sticky kit --><script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet">
<script src="../pkgdown.js"></script><link href="../extra.css" rel="stylesheet">
<meta property="og:title" content="Timestamping with Events Data">
<meta property="og:description" content="">
<meta property="og:image" content="/logo.png">
<meta name="twitter:card" content="summary">
<!-- mathjax --><script src="https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container template-article">
<header><div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">ghtrackr</a>
<span class="label label-default" data-toggle="tooltip" data-placement="bottom" title="Released package">0.0.0.9000</span>
</span>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="../index.html">
<span class="fa fa-home"></span>
</a>
</li>
<li>
<a href="../articles/index.html">Articles</a>
</li>
<li>
<a href="../reference/index.html">Documentation</a>
</li>
<li>
<a href="../news/index.html">News</a>
</li>
<li>
<a href="../CREDITS.html">Credits</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://github.com/emilyriederer/ghtrackr/">
<span class="fa fa-github"></span>
</a>
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
<!--/.container -->
</div>
<!--/.navbar -->
</header><div class="row">
<div class="col-md-9 contents">
<div class="page-header toc-ignore">
<h1>Timestamping with Events Data</h1>
<h4 class="author">Emily Riederer</h4>
<h4 class="date">2019-01-05</h4>
<small class="dont-index">Source: <a href="https://github.com/emilyriederer/ghtrackr/blob/master/vignettes/events-data.Rmd"><code>vignettes/events-data.Rmd</code></a></small>
<div class="hidden name"><code>events-data.Rmd</code></div>
</div>
<p>Events data, as returned by <code><a href="../reference/get_issue_events.html">get_issue_events()</a></code>, provides a granular view of issues in your GitHub repository. As opposed to the issue-level data returned by <code><a href="../reference/get_issues.html">get_issues()</a></code>, <code><a href="../reference/get_issue_events.html">get_issue_events()</a></code> provides timestamped event-level data for each issue, such as the addition and deletion of labels and milestones. See the <a href="https://developer.github.com/v3/issues/events/">Issue Events GitHub API documentation</a> for a more comprehensive list.</p>
<p>This detailed information has many potential uses. One use in reporting and visualization is if if the <code>created_at</code> date for your issues does not have an intrinsic meaning and does not represent when work on an issue was started.</p>
<p>For example, let’s suppose we pull some issues from our repo and visualize their time-to-completion with <code><a href="../reference/viz_gantt.html">viz_gantt()</a></code>.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">my_repo <-<span class="st"> </span><span class="kw"><a href="../reference/create_repo_ref.html">create_repo_ref</a></span>(<span class="st">'emilyriederer'</span>, <span class="st">'my_repo'</span>)
issues <-<span class="st"> </span><span class="kw"><a href="../reference/get_issues.html">get_issues</a></span>(experigit, <span class="dt">state =</span> <span class="st">'closed'</span>, <span class="dt">milestone =</span> <span class="dv">1</span>) <span class="op">%>%</span><span class="st"> </span><span class="kw"><a href="../reference/parse_issues.html">parse_issues</a></span>()</code></pre></div>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw"><a href="../reference/viz_gantt.html">viz_gantt</a></span>(issues)</code></pre></div>
<p><img src="events-data_files/figure-html/unnamed-chunk-3-1.png" width="700"></p>
<p>Issue 1 stands out as having taken a very long time to complete. However, it’s possible it was created long before anyone started actively working on it. Instead, we might want to consider the start time to be, for example, when an issue was tagged with the “in-progress label”.</p>
<p>We can get events for a specific issue with the following code. Due to the potentially massive size of this data, the function returns events for a single issue at a time and, thus, has a required <code>number</code> parameter to specify the issue for which events should be returned. As such, to events for multiple issues, we need to use <code><a href="https://purrr.tidyverse.org/reference/map.html">purrr::map()</a></code>.</p>
<p>Since events can also include adding assignees or milestones, we filter our dataset to <code>'labeled'</code> events where the <code>label_name</code> is “in-progress”.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">issue_events <-<span class="st"> </span>
<span class="st"> </span>purrr<span class="op">::</span><span class="kw"><a href="https://purrr.tidyverse.org/reference/map.html">map</a></span>(<span class="dv">1</span><span class="op">:</span><span class="dv">3</span>, <span class="op">~</span><span class="kw"><a href="../reference/get_issue_events.html">get_issue_events</a></span>(experigit, <span class="dt">number =</span> .)) <span class="op">%>%</span><span class="st"> </span>
<span class="st"> </span>purrr<span class="op">::</span><span class="kw"><a href="https://purrr.tidyverse.org/reference/map.html">map_df</a></span>(parse_issue_events) <span class="op">%>%</span>
<span class="st"> </span>dplyr<span class="op">::</span><span class="kw"><a href="http://dplyr.tidyverse.org/reference/filter.html">filter</a></span>(event <span class="op">==</span><span class="st"> 'labeled'</span> <span class="op">&</span><span class="st"> </span>label_name <span class="op">==</span><span class="st"> 'in-progress'</span>)</code></pre></div>
<p>The fields of the resulting dataframe are shown below. Note that in this dataset, the <code>created_at</code> field refers to when the <em>event</em> was created (i.e. when the issue was labelled in this case) and not when the <em>issue</em> was created.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">head</span>(issue_events)
<span class="co">#> number id actor_login event created_at label_name milestone_title</span>
<span class="co">#> 1 1 123 emilyriederer labeled 2018-04-15 in-progress NA</span>
<span class="co">#> 2 2 124 emilyriederer labeled 2018-04-02 in-progress NA</span>
<span class="co">#> 3 3 125 emilyriederer labeled 2018-04-20 in-progress NA</span>
<span class="co">#> assignee_login assigner_login</span>
<span class="co">#> 1 NA NA</span>
<span class="co">#> 2 NA NA</span>
<span class="co">#> 3 NA NA</span></code></pre></div>
<p>Next, we can join our datasets together. THe <code>suffix</code> parameter allows us to append <code>_event</code> to all the field names from the events data to distinguished between the issue and event <code>created_at</code> fields.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">issue_with_events <-<span class="st"> </span>dplyr<span class="op">::</span><span class="kw"><a href="http://dplyr.tidyverse.org/reference/join.html">inner_join</a></span>(issues, issue_events, <span class="dt">by =</span> <span class="st">"number"</span>, <span class="dt">suffix =</span> <span class="kw">c</span>(<span class="st">""</span>, <span class="st">"_event"</span>))</code></pre></div>
<p>Finally, we can use this new dataset to remake our plot by specifying the new <code>created_at_event</code> variable as the appropriate issue start date, via the optional <code>start</code> parameter.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw"><a href="../reference/viz_gantt.html">viz_gantt</a></span>(issue_with_events, <span class="dt">start =</span> created_at_event)</code></pre></div>
<p><img src="events-data_files/figure-html/unnamed-chunk-7-1.png" width="700"></p>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
</div>
</div>
<footer><div class="copyright">
<p>Developed by Emily Riederer.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="http://pkgdown.r-lib.org/">pkgdown</a>.</p>
</div>
</footer>
</div>
</body>
</html>