Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Cleaned out some stray files

  • Loading branch information...
commit 4dbd6e43667c8011cf1cbd8770e15ec7517ce239 1 parent ffd1165
@evenwestvang evenwestvang authored
Showing with 0 additions and 194 deletions.
  1. +0 −57 snippets/longest_delay.sql
  2. +0 −123 snippets/r_scripts.r
  3. +0 −14 snippets/ruby.rb
View
57 snippets/longest_delay.sql
@@ -1,57 +0,0 @@
-
-# longest case delays
-
-select substr(title, 1, 40), document_id, avg_time from (
- select e1.case_document_id as case_id, avg(e2.document_date - e1.document_date) as avg_time from exchanges e1
- join exchanges e2
- on e1.case_document_id = e2.case_document_id and e2.document_date > e1.document_date and e2.description != 'Komplett elektronisk sak' and
- not exists (
- select true from exchanges e3 where
- e1.case_document_id = e3.case_document_id and e3.document_date < e2.document_date and e3.document_date > e1.document_date
- )
- where e1.incoming = true and e2.incoming = false group by e1.case_document_id order by avg_time desc
-) as q join cases on cases.document_id = case_id limit 100;
-
-
-# shortest case worker delay
-
-select parties.name, parties.id, time from
- (select case_worker_id, avg(avg_time) as time from (
- select e1.case_document_id as case_id, avg(e2.document_date - e1.document_date) as avg_time from exchanges e1
- join exchanges e2
- on e1.case_document_id = e2.case_document_id and e2.document_date > e1.document_date and e2.description != 'Komplett elektronisk sak' and
- not exists (
- select true from exchanges e3 where
- e1.case_document_id = e3.case_document_id and e3.document_date < e2.document_date and e3.document_date > e1.document_date
- )
- where e1.incoming = true and e2.incoming = false group by e1.case_document_id
- ) as q join cases on cases.document_id = case_id group by case_worker_id)q2
-join parties on case_worker_id = parties.id order by time asc;
-
-
-# department delay by month
-
-drop table if exists tmp_case_dept_time;
-create table tmp_case_dept_time (
- unit text,
- month date,
- delay float
-);
-
-insert into tmp_case_dept_time
- select cases.processing_unit as unit, date_trunc('month', e2.document_date) as trunc_month, avg(e2.document_date - e1.document_date) as avg_time from exchanges e1
- join exchanges e2
- on e1.case_document_id = e2.case_document_id and e2.document_date > e1.document_date and e2.description != 'Komplett elektronisk sak' and
- not exists (
- select true from exchanges e3 where
- e1.case_document_id = e3.case_document_id and e3.document_date < e2.document_date and e3.document_date > e1.document_date
- )
- join cases on cases.document_id = e1.case_document_id
- where e1.incoming = true and e2.incoming = false group by cases.processing_unit, trunc_month;
-
-copy tmp_case_dept_time to '/tmp/case_dept_time.csv' with csv header;
-
-#in 'r'
-
-foo <- read.csv("/Users/even/projects/visuals/planar/tmp/case_dept_time.csv", head=TRUE, sep=",")
-
View
123 snippets/r_scripts.r
@@ -1,123 +0,0 @@
-con <- dbConnect(PostgreSQL(), dbname="planar_development")
-rs <- dbSendQuery(con, "select initiated_at, kind from cases")
-data <- fetch(rs, n = -1)
-attach(data)
-
-plot(initiated_at, initiated_at, col=rgb(0,0,0,20,maxColorValue=255), cex=0.1, pch=16)
-
-
-h <- hist(initiated_at, breaks=400)
-
-
----
-
-byggsesaker
-
-
-con <- dbConnect(PostgreSQL(), dbname="planar_development")
-rs <- dbSendQuery(con, "select initiated_at, kind from cases where kind = 'Byggesak'")
-data <- fetch(rs, n = -1)
-attach(data)
-
-h <- hist(initiated_at, breaks="months", main="Byggesaker per måned")
-h <- hist(initiated_at, breaks="years", main="Byggesaker per måned")
-
-----
-
-scatterplot av koresspondanse og saker
---------------------------------------
-
-
-
-
-
-# ** SQL **
-
-
-con <- dbConnect(PostgreSQL(), dbname="planar_development")
-rs <- dbSendQuery(con, "select initiated_at, kind from cases")
-cases <- fetch(rs, n = -1)
-
-
-# SETUP - ** COLS **
-
-alpha <- 30
-nice_cols <- c(rgb(50,68,82,alpha, maxColorValue=255), rgb(151,189,191, alpha, maxColorValue=255), rgb(242,223,187, alpha, maxColorValue=255), rgb(242,135,5, alpha, maxColorValue=255))
-palette(nice_cols)
-kinds <- c("Byggesak", "Forespørsel", "Måle-/delesak", "Plansaker")
-par(lwd=0.5)
-
-
-# ** EXCHANGES **
-con <- dbConnect(PostgreSQL(), dbname="planar_development")
-rs <- dbSendQuery(con, "select cases.initiated_at as case_date, exchanges.journal_date as exchange_date, cases.kind from exchanges join cases on case_document_id = cases.document_id")
-exchanges <- fetch(rs, n = -1)
-
-# ** EXCHANGES OUTGOING **
-con <- dbConnect(PostgreSQL(), dbname="planar_development")
-rs <- dbSendQuery(con, "select cases.initiated_at as case_date, exchanges.journal_date as exchange_date, cases.kind, row_number() OVER ( order by initiated_at) from exchanges join cases on case_document_id = cases.document_id")
-exchanges <- fetch(rs, n = -1)
-
-# ** EXCHANGES WITH ROW NUMBERS **
-con <- dbConnect(PostgreSQL(), dbname="planar_development")
-rs <- dbSendQuery(con, "select cases.initiated_at as case_date, exchanges.journal_date as exchange_date, cases.kind, rank() OVER (order by initiated_at) from exchanges join cases on case_document_id = cases.document_id order by case_date asc")
-exchanges <- fetch(rs, n = -1)
-
-# ** EXCHANGES WITH ROW NUMBERS 'BYGGESAK' **
-con <- dbConnect(PostgreSQL(), dbname="planar_development")
-rs <- dbSendQuery(con, "select cases.initiated_at as case_date, exchanges.journal_date as exchange_date, cases.kind, rank() OVER (order by initiated_at) from exchanges join cases on case_document_id = cases.document_id where kind = 'Byggesak' and incoming = false")
-exchanges <- fetch(rs, n = -1)
-
-
-
-# ** CHOP **
-
-exchanges <- subset(exchanges, case_date > as.Date('2001-2-1') & exchange_date > as.Date('2001-2-1'))
-
-
-options(scipen=6)
-
-# ** PLOT **
-
-
-# ** exchanges: small dots **
-plot(exchanges_chop$exchange_date, exchanges_chop$case_date, col=rgb(0,0,0,90,maxColorValue=255), cex=0.06, pch=16,
-axes=TRUE, main="Saksgang", xlab="", ylab="")
-
-# ** exchanges: small dots ranked **
-plot(exchanges$case_date, exchanges$rank, col=rgb(0,0,0,90,maxColorValue=255), cex=0.06, pch=16,
-axes=TRUE, main="Saksgang", xlab="", ylab="")
-
-
-
-
-
-# ** exchanges: colored dots varying cols **
-plot(exchanges_chop$exchange_date, exchanges_chop$case_date, col=match(exchanges_chop$kind, kinds), cex=0.06 + (match(exchanges_2010$kind, kinds)/15), pch=16,
-axes=TRUE, main="Saksgang", xlab="", ylab="")
-legend("topleft", inset=.05,
- kinds, fill=nice_cols, horiz=TRUE)
-
-
-# ** ranked exchanges: colored dots varying cols **
-plot(exchanges$exchange_date, exchanges$rank, col=match(exchanges$kind, kinds), cex=0.06 + (match(exchanges$kind, kinds)/15), pch=16,
-axes=TRUE, main="Saksgang", xlab="", ylab="")
-legend("topleft", inset=.05,
- kinds, fill=nice_cols, horiz=TRUE)
-
-
-
-# ** plot a subset **
-
-exchanges_2010 <- subset(exchanges, case_date > as.Date('2010-1-1') & exchange_date > as.Date('2010-1-1'))
-
-plot(exchanges_2010$exchange_date, exchanges_2010$case_date, col=match(exchanges_2010$kind, kinds), cex=0.1 + (match(exchanges_2010$kind, kinds)/10), pch=16, axes=TRUE, main="Saksgang", xlab="", ylab="")
-
-legend("topleft", inset=.05,
- kinds, fill=nice_cols, horiz=TRUE)
-
-# ggplot 2
-
-
-p <- ggplot(exchanges_chop, aes(exchange_date, case_date))
-p + geom_point()
View
14 snippets/ruby.rb
@@ -1,14 +0,0 @@
-linkage_list = {}
-links = []
-
-while everyone_involved.length > 1
- everyone_involved[1..-1].each do |p|
- link = [everyone_involved[0], p]
- key = link.map(&:canonical_id).sort.join("_")
- unless linkage_list[key]
- links << link
- linkage_list[key] = true
- end
- end
- everyone_involved.shift
-end
Please sign in to comment.
Something went wrong with that request. Please try again.