Skip to content

Commit

Permalink
a bunch of changes and some clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
cdav18 committed Jan 9, 2015
1 parent f3ed294 commit 850f4a0
Show file tree
Hide file tree
Showing 10 changed files with 320 additions and 224 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
*.iml
.idea
/target
.gradle
/target
/buildPlugins
/build
application.properties
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# measurementor
measurementor helps you visualize data from your development cycle to help you be a better team.
TODO talk about it more here...

# Getting Started
First note the [vagrant file](https://www.vagrantup.com/). That will call the [puppet](http://puppetlabs.com/) manifest
Expand All @@ -14,7 +15,10 @@ Run the measurementor grails app inside the vagrant box by updating the shared
This is still a bit of a work in progress but feel free to let me know if there's anything that could be better.
thanks!

When jobs run by default they'll get the last month of activity. Use the interface to get a full history of a project.

# Other Stuff

logs get output to /tmp/log/measurementor.log.


38 changes: 38 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.grails:grails-gradle-plugin:2.1.0"
}
}
apply plugin: 'grails'

grails {
grailsVersion = '2.4.3' // Specifies the Grails version to use
groovyVersion = '2.3.6' // Specify the Groovy version to use (should match the version that ships with the above Grails version)
springLoadedVersion = '1.2.0.RELEASE' // Specify the Spring Loaded version to use
}

repositories {
jcenter()
grails.central() //Adds the Grails Central Repository for resolving Grails plugins (replaces grailsPlugins(), grailsCentral() from BuildConfig.groovy)
}

dependencies {
bootstrap 'org.grails.plugins:tomcat:7.0.50.1'

compile 'org.grails.plugins:scaffolding:2.0.2'
compile 'org.grails.plugins:cache:1.1.1'

runtime 'org.grails.plugins:hibernate:3.6.10.8' //or 'org.grails.plugins:hibernate4:4.3.1.1'
runtime 'org.grails.plugins:database-migration:1.3.8'
runtime 'org.grails.plugins:jquery:1.11.0'
runtime 'org.grails.plugins:resources:1.2.2'

compile 'org.grails.plugins:rest:0.8'
compile 'org.grails.plugins:mongodb:3.0.2'
compile 'org.grails.plugins:quartz:1.0.2'
compile 'org.grails.plugins:elasticsearch:0.0.3.6'

}
58 changes: 4 additions & 54 deletions grails-app/conf/BootStrap.groovy
Original file line number Diff line number Diff line change
@@ -1,61 +1,11 @@
import org.cwhd.measure.configuration.SourceType
import org.cwhd.measure.system.JobHistory

import javax.xml.transform.Source
import java.util.concurrent.TimeUnit

class BootStrap {
def jiraDataService
def stashDataService
def grailsApplication
def updateDataFromSourceService

def init = { servletContext ->

println "GO!"
//TODO in

def result = "unknown"
try {
def startDateTime = new Date()
def lastJob = JobHistory.list([max:1,sort:"jobDate",order:"desc"])
println "---------------------------------------------------"
println "last job:" + lastJob[0].jobDate + " result: " + lastJob[0].jobResult
println "---------------------------------------------------"

//TODO i should get all the projects from somewhere, probably a configuration DB
//TODO i should only get data that's changed since the last time the job ran...i should be able to figure
//that out from the jobHistory table
//stashDataService.getAll()
//BIG, CIV, CPCQA
/*
for(source in SourceType.findAll()) {
if(source.systemName == SourceType.SystemName.JIRA) {
jiraDataService.getData(0, 100, source.sourceName, null)
} else if(source.SystemName == SourceType.SystemName.STASH) {
//stashDataService.getAll()
}
}
*/
//jiraDataService.getData(0, 100, "NGAP", null)
//jiraDataService.getData(0, 100, "RPA", null)
//jiraDataService.getData(0, 100, "DCBI", null)
jiraDataService.getData(0, 100, "CPC", null)
//DCBI, RPA, NGAP, CPC
//jiraDataService.reIndexEC()
def doneDateTime = new Date()
def difference = doneDateTime.getTime() - startDateTime.getTime()
def minutesDiff = TimeUnit.MILLISECONDS.toMinutes(difference)
result = "success in $difference ms"
println "---------------------------------------------------"
println "ALL DONE IN ~$minutesDiff minutes"
println "---------------------------------------------------"
} catch (Exception ex) {
result = "FAIL: $ex.message"
println "FAIL: $ex"
if(grailsApplication.config.runOnStartup) {
updateDataFromSourceService.getAllData()
}

JobHistory history = new JobHistory(jobDate: new Date(), jobResult: result)
history.save(failOnError: true)

}
def destroy = {
}
Expand Down
51 changes: 29 additions & 22 deletions grails-app/conf/DataSource.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,36 @@ environments {
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
properties {
// See http://grails.org/doc/latest/guide/conf.html#dataSource for documentation
jmxEnabled = true
initialSize = 5
maxActive = 50
minIdle = 5
maxIdle = 25
maxWait = 10000
maxAge = 10 * 60000
timeBetweenEvictionRunsMillis = 5000
minEvictableIdleTimeMillis = 60000
validationQuery = "SELECT 1"
validationQueryTimeout = 3
validationInterval = 15000
testOnBorrow = true
testWhileIdle = true
testOnReturn = false
jdbcInterceptors = "ConnectionState"
defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
grails {
mongo {
host = "localhost"
port = 27017
databaseName = "test"
}
}
// dataSource {
// dbCreate = "update"
// url = "jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
// properties {
// // See http://grails.org/doc/latest/guide/conf.html#dataSource for documentation
// jmxEnabled = true
// initialSize = 5
// maxActive = 50
// minIdle = 5
// maxIdle = 25
// maxWait = 10000
// maxAge = 10 * 60000
// timeBetweenEvictionRunsMillis = 5000
// minEvictableIdleTimeMillis = 60000
// validationQuery = "SELECT 1"
// validationQueryTimeout = 3
// validationInterval = 15000
// testOnBorrow = true
// testWhileIdle = true
// testOnReturn = false
// jdbcInterceptors = "ConnectionState"
// defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
// }
// }
}
}
9 changes: 8 additions & 1 deletion grails-app/domain/org/cwhd/measure/system/JobHistory.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@ package org.cwhd.measure.system
class JobHistory {
static mapWith = "mongo"

Date jobDate
Date startDate
Long completionTime //this is in minutes
String jobResult
String jobNotes
String projectCount

static constraints = {
completionTime nullable: true
jobResult nullable: true
jobNotes nullable: true
projectCount nullable: true
}
}
43 changes: 10 additions & 33 deletions grails-app/jobs/org/cwhd/measure/PopulatorJob.groovy
Original file line number Diff line number Diff line change
@@ -1,46 +1,23 @@
package org.cwhd.measure

import org.cwhd.measure.system.JobHistory

import java.util.concurrent.TimeUnit

import org.apache.commons.logging.LogFactory
/**
* the main job that calls all the services to get data. note that history
* is stored in mongo along with everything else
*/
class PopulatorJob {
def jiraDataService
def stashDataService
private static final logger = LogFactory.getLog(this)
def updateDataFromSourceService

static triggers = {
simple startDelay: 5000l, repeatCount:0
//wait an hour to start, repeat every 8 hours
simple startDelay: 3600000, repeatInterval: 28800000, repeatCount:-1
}

//TODO this would be best if i can pass in the last date this ran...
//if i have that date, then query for all changes since last run
//if i don't have it get everything!
def execute() {

/*
def result = "unknown"
try {
def startDateTime = new Date()
jiraDataService.getData(0, 100, "ACOE")
stashDataService.getAll()
def doneDateTime = new Date()
def difference = doneDateTime.getTime() - startDateTime.getTime()
def minutesDiff = TimeUnit.MILLISECONDS.toMinutes(difference)
result = "success in $difference ms"
println "---------------------------------------------------"
println "ALL DONE IN ~$minutesDiff minutes"
println "---------------------------------------------------"
} catch (Exception ex) {
result = "FAIL: $ex.message"
}
JobHistory history = new JobHistory(jobDate: new Date(), jobResult: result)
history.save(failOnError: true)
*/
logger.info("----------------------------------")
logger.info("STARTING TIMED JOB")
logger.info("----------------------------------")
updateDataFromSourceService.getAllData()
}
}
}
Loading

0 comments on commit 850f4a0

Please sign in to comment.