-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboilerplate.py
128 lines (112 loc) · 3.44 KB
/
boilerplate.py
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
marker_boilerplate = """"var marker = new google.maps.Marker({
position: {lat: markerData.lat, lng: markerData.lng},
map: map,
title: markerData.name + ' - ' + markerData.address,
label: markerData.name
});
"""
holding_period_boilerplate = """
WITH sale_deltas AS (
SELECT
cs1.condo_unit_id,
cs1.closing_date AS current_closing_date,
cs2.closing_date AS previous_closing_date,
(cs1.closing_date - cs2.closing_date) AS delta_days
FROM
core_condosale cs1
JOIN
core_condosale cs2
ON
cs1.condo_unit_id = cs2.condo_unit_id
WHERE
cs1.closing_date > cs2.closing_date
AND cs1.blacklist = FALSE
AND cs2.blacklist = FALSE
AND cs2.closing_date = (
SELECT MAX(cs3.closing_date)
FROM core_condosale cs3
WHERE cs3.condo_unit_id = cs1.condo_unit_id
AND cs3.closing_date < cs1.closing_date
AND cs3.blacklist = FALSE
)
AND cs1.condo_unit_id IN (
SELECT id
FROM core_condounit
WHERE blacklist = FALSE
AND building_id IN (
SELECT id
FROM core_condobuilding
WHERE market_id = (
SELECT id FROM core_condomarket WHERE name = 'Brickell'
)
)
)
)
SELECT
AVG(delta_days) AS average_delta
FROM
sale_deltas;
"""
two_bed_holding_period_boilerplate = """
WITH sale_deltas AS (
SELECT
cs1.condo_unit_id,
cs1.closing_date AS current_closing_date,
cs2.closing_date AS previous_closing_date,
(cs1.closing_date - cs2.closing_date) AS delta_days
FROM
core_condosale cs1
JOIN
core_condosale cs2
ON
cs1.condo_unit_id = cs2.condo_unit_id
WHERE
cs1.closing_date > cs2.closing_date
AND cs1.blacklist = FALSE
AND cs2.blacklist = FALSE
AND cs2.closing_date = (
SELECT MAX(cs3.closing_date)
FROM core_condosale cs3
WHERE cs3.condo_unit_id = cs1.condo_unit_id
AND cs3.closing_date < cs1.closing_date
AND cs3.blacklist = FALSE
)
AND cs1.condo_unit_id IN (
SELECT id
FROM core_condounit
WHERE blacklist = FALSE
AND beds = 2
AND building_id IN (
SELECT id
FROM core_condobuilding
WHERE market_id = (
SELECT id FROM core_condomarket WHERE name = 'Brickell'
)
)
)
)
SELECT
AVG(delta_days) AS average_delta
FROM
sale_deltas;
"""
javascript_map_boilerplate = """
function initMap() {
var locations = [
// Building and school markers will be listed here
];
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 13,
center: {lat: [average_lat], lng: [average_lng]}
});
locations.forEach(function(location) {
var marker = new google.maps.Marker({
position: {lat: location.lat, lng: location.lng},
map: map,
label: location.label
});
});
}
"""
building_marker_format_boilerplate = "{lat: [building.lat], lng: [building.lon], label: '[building.alt_name] - [building.address]'}"
school_marker_format_boilerplate = "{lat: [school.geometry.location.lat], lng: [school.geometry.location.lng], label: '[school.name]'}"