Created
March 29, 2020 20:10
-
-
Save serradura/7a2e17d97579df463349766e1cd86559 to your computer and use it in GitHub Desktop.
Export AppSignal deploys as CSV using artoo.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Steps: | |
// 1. Open your browser console | |
// 2. Enable artoo.js (http://medialab.github.io/artoo/) | |
// 3. Replace USER_OR_ORG and REPO in the COMMIT_URL and COMPARE_URL | |
// 4. Copy paste the following script in the console | |
var COMMIT_URL = 'https://gitlab.com/USER_OR_ORG/REPO/-/commit/'; | |
var COMPARE_URL = 'https://gitlab.com/USER_OR_ORG/REPO/-/compare/'; | |
var $rows = artoo.$('.deploys tr').filter(':not(.table-title)'); | |
var headers = $rows.filter('.column-titles').find('th').map(function() { | |
return $(this).text().toLowerCase().replace(' ', '_') | |
}).get(); | |
var deploys = $rows.filter(':not(.column-titles)').map(function(index) { | |
var data = {}, values = $(this).find('td').map(function(i) { | |
var $td = $(this); | |
if (i < 2) return $td.find('[title]').attr('title'); | |
if (i > 1) return $td.text(); | |
}).get() | |
$.each(headers, function(i, header) { | |
data[header] = values[i] | |
}); | |
var deployedOn = values[0]; | |
var revision = values[1]; | |
data['date'] = deployedOn.substring(0, 10); | |
data['hour'] = deployedOn.substring(11, 16); | |
if (revision.indexOf(' ') > 0) { // No deploy yet | |
data['commit'] = null; | |
} else { | |
data['commit'] = COMMIT_URL + revision; | |
} | |
return data; | |
}).get(); | |
$.each(deploys, function(i, deploy) { | |
var revisionProp = headers[1]; | |
var previousDeploy = deploys[i + 1]; | |
if (previousDeploy) { | |
if (deploy['commit'] && previousDeploy['commit']) { | |
var revision = deploy[revisionProp]; | |
var previousRevision = previousDeploy[revisionProp]; | |
var range = revision + '...' + previousRevision; | |
deploy['compare'] = COMPARE_URL + range; | |
} else { | |
deploy['compare'] = deploy['commit']; | |
} | |
} else { | |
deploy['compare'] = deploy['commit']; | |
} | |
}); | |
console.log('Deploys: ', deploys.length) | |
artoo.saveCsv(deploys); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment