Skip to content
Permalink
Browse files

saving work to have a mental breakdown

  • Loading branch information...
james-tyner committed Apr 24, 2019
1 parent 110e6c0 commit 1e8af9c6d2f841f4196a4c8a8b4363594e14e65f
7 app.js
@@ -38,11 +38,18 @@ app.get('/', function (req, res) {
val = val.toString().replace(/(\d+)(\d{3})/, '$1'+','+'$2');
}
return val;
},
truncate:function(val){
return val.slice(0,6);
}
}
});
});

app.get("/articles/activity", function(req, res){
res.render('articles/activity-overview', {layout:false})
})

app.use(compression());
app.use(express.static("public"));

@@ -10,15 +10,29 @@
connection = sqlite3.connect("permit_data.db")
cursor = connection.cursor()


summaryData["sum"] = {}
### TOTAL NUMBER OF UNITS APPROVED IN THE CITY
cursor.execute("SELECT SUM(UnitsAll) FROM attributes;")
# Remember, it has to be a for loop because that's just how it is
for result in cursor:
summaryData["sum"] = result[0]
summaryData["sum"]["all_time"] = result[0]

### TOTAL NUMBER APPROVED IN THE CITY BY YEAR
cursor.execute("SELECT SUM(Units2013), SUM(Units2014), SUM(Units2015), SUM(Units2016), SUM(Units2017), SUM(Units2018), SUM(Units2019) FROM attributes;")
for result in cursor:
summaryData["sum"][2013] = result[0]
summaryData["sum"][2014] = result[1]
summaryData["sum"][2015] = result[2]
summaryData["sum"][2016] = result[3]
summaryData["sum"][2017] = result[4]
summaryData["sum"][2018] = result[5]
summaryData["sum"][2019] = result[6]


### TOP FIVE MOST ACTIVE ZIP CODES
summaryData["top-five"] = []
cursor.execute("SELECT ZIP, Description, UnitsAll FROM attributes ORDER BY UnitsAll DESC LIMIT 5;")
cursor.execute("SELECT ZIP, Description, UnitsAll FROM attributes ORDER BY UnitsAll DESC LIMIT 10;")
for result in cursor:
summaryData["top-five"].append({
"zip":result[0],
@@ -28,14 +42,19 @@

### TOP FIVE LEAST ACTIVE ZIP CODES
summaryData["least-five"] = []
cursor.execute("SELECT ZIP, Description, UnitsAll FROM attributes ORDER BY UnitsAll ASC LIMIT 5;")
cursor.execute("SELECT ZIP, Description, UnitsAll FROM attributes ORDER BY UnitsAll ASC LIMIT 15;")
for result in cursor:
summaryData["least-five"].append({
"zip":result[0],
"description":result[1],
"units":result[2]
})

### AVERAGE CONSTRUCTION FOR NEW ZIP CODES
cursor.execute("SELECT AVG(UnitsAll) FROM attributes;")
for result in cursor:
summaryData["average"] = result[0]

### STATIC: MEDIAN RENT, INCOME, PERCENTAGE SPENT ON HOUSING
# 2017 American Communities Survey, city of Los Angeles
medianCosts = 1467
@@ -0,0 +1,40 @@
.article-main {
width:90vw;
margin-left:5vw;
margin-top:5em;

.article-title {
font-size:3em;
margin-bottom:0;
}

.article-container {
width:100%;
max-width:600px;
margin:auto;

p {
line-height:1.75em;
}

.chart-container {
position:relative;
width:100%;
}
}

footer {
position:relative;
top:4em;
max-width:600px;
margin:auto;

small {
display:block;

&:last-of-type {
padding-bottom:2em;
}
}
}
}

Large diffs are not rendered by default.

@@ -413,6 +413,7 @@ h1 {
}

@import 'info';
@import 'articles';

// RESPONSIVE
@import 'responsive';
@@ -132,9 +132,14 @@ <h2>All Projects</h2>
</div>

<footer>
<small>Housing data comes from the <a href="//data.lacity.org">City of Los Angeles open data portal</a>. Metro Rail station data comes from the <a href="https://developer.metro.net/introduction/gis-data/download-gis-data/">Los Angeles County Metropolitan Transportation Authority</a>.</small>
<h3>About the data</h3>
<small>Buildings permits data come from the <a href="//data.lacity.org">city of Los Angeles open data portal</a>. This dataset includes only housing approved under the jurisdiction of the city of Los Angeles, so other cities (like Santa Monica or Burbank) and unincorporated LA County land (like Willowbrook or Marina Del Rey) are not included.</small>
<br>
<small>Demographic data comes from the US Census Bureau 2017 American Communities Survey. </small>
<small>Metro Rail station data comes from the <a href="https://developer.metro.net/introduction/gis-data/download-gis-data/">Los Angeles County Metropolitan Transportation Authority</a>.</small>
<br>
<small>Demographic data (including housing costs and median income) comes from the US Census Bureau 2017 American Communities Survey.</small>
<br>
<small>For weekly emails: Your email address will be stored on a secure server. Emails are sent via SendGrid, an industry-standard tool, over an encrypted connection.</small>
<br>
<small>&copy; 2019 James Tyner</small>
</footer>
@@ -0,0 +1,69 @@
Chart.defaults.global.defaultFontFamily = 'Roboto Condensed';

var yearlyChart = document.getElementById('yearly-chart').getContext('2d');
var chart1 = new Chart(yearlyChart, {
// The type of chart we want to create
type: 'bar',

// The data for our dataset
data: {
labels: ['2013', '2014', '2015', '2016', '2017', '2018'],
datasets: [{
label: 'New housing units approved',
backgroundColor: '#333333',
hoverBackgroundColor:"#754aed",
data: [761, 2326, 8003, 14604, 14656, 17090]
}]
},

// Configuration options go here
options: {}
});

var mostActiveChart = document.getElementById("most-active-chart").getContext("2d");
var chart2 = new Chart(mostActiveChart, {
type:"bar",
data:{
labels:["90015: South Park", "90094: Playa Vista", "90014: Los Angeles", "91601: North Hollywood", "90028: Hollywood", "90045: LAX Area / Westchester", "90026: Echo Park / Silver Lake", "91367: Woodland Hills", "90012: Civic Center / Chinatown", "90025: Sawtelle / West LA"],
datasets:[{
label:"New housing units approved",
backgroundColor:"#333333",
hoverBackgroundColor:"#1dcc70",
data:[4558, 2661, 2299, 2260, 2213, 1887, 1426, 1419, 1398, 1397]
}]
},
options:{
title:{
text:"Los Angeles ZIP codes with the most new housing units approved",
fontSize:14,
fontFamily:"Roboto",
fontWeight:"bold",
fontColor:"#1b2c42",
display:true
}
}
})

var leastActiveChart = document.getElementById("least-active-chart").getContext("2d");
var chart3 = new Chart(leastActiveChart, {
type:"bar",
data:{
labels:["*91504: Burbank / Glenoaks", "*90717: Lomita / Rancho Palos Verdes", "*91505: Burbank", "*91105: Pasadena", "*91214: La Crescenta", "*90212: Beverly Hills", "*91205: Glendale / Tropico", "90732: Rancho Palos Verdes", "*90063: City Terrace", "*91340: San Fernando", "*90402: Santa Monica", "90293: Playa del Rey", "91344: Granada Hills", "91345: Mission Hills", "91307: West Hills"],
datasets:[{
label:"New housing units approved",
backgroundColor:"#333333",
hoverBackgroundColor:"#1dcc70",
data:[0, 0, 0, 1, 1, 1, 2, 11, 17, 17, 18, 20, 35, 37, 38]
}]
},
options:{
title:{
text:"Los Angeles ZIP codes with the fewest new housing units approved",
fontSize:14,
fontFamily:"Roboto",
fontWeight:"bold",
fontColor:"#1b2c42",
display:true
}
}
})
@@ -25,10 +25,45 @@
"units": 2213,
"description": "Hollywood ",
"zip": 90028
},
{
"units": 1887,
"description": "LAX Area / Westchester ",
"zip": 90045
},
{
"units": 1426,
"description": "Echo Park / Silverlake ",
"zip": 90026
},
{
"units": 1419,
"description": "Woodland Hills ",
"zip": 91367
},
{
"units": 1398,
"description": "Civic Center / Chinatown ",
"zip": 90012
},
{
"units": 1397,
"description": "Sawtelle / West LA ",
"zip": 90025
}
],
"sum": 62489,
"average": 545.1652173913044,
"median-income": 54501,
"sum": {
"2016": 14604,
"2017": 14656,
"2018": 17090,
"2019": 5254,
"all_time": 62694,
"2013": 761,
"2014": 2326,
"2015": 8003
},
"least-five": [
{
"units": 0,
@@ -54,6 +89,56 @@
"units": 1,
"description": "La Crescenta",
"zip": 91214
},
{
"units": 1,
"description": "Beverly Hills",
"zip": 90212
},
{
"units": 2,
"description": "Glendale (Tropico)",
"zip": 91205
},
{
"units": 11,
"description": "Rancho Palos Verdes",
"zip": 90732
},
{
"units": 17,
"description": "City Terrace",
"zip": 90063
},
{
"units": 17,
"description": "San Fernando",
"zip": 91340
},
{
"units": 18,
"description": "Santa Monica",
"zip": 90402
},
{
"units": 20,
"description": "Playa del Rey ",
"zip": 90293
},
{
"units": 35,
"description": "Granada Hills ",
"zip": 91344
},
{
"units": 37,
"description": "Mission Hills ",
"zip": 91345
},
{
"units": 38,
"description": "West Hills ",
"zip": 91307
}
],
"median-monthly-costs": 1467
@@ -3,5 +3,6 @@ def getAndSend():
import lib.obtainData # fill in the projects table
import lib.createGeoJSON # create GeoJSON files for each ZIP code
import lib.calculateYearlyUnits # update the number of units per year
import lib.createSummaryFile # update the summary file used by the homepage

import runSendEmail

0 comments on commit 1e8af9c

Please sign in to comment.
You can’t perform that action at this time.