Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix slack message request id * Add tokens to requests * Upload pano with token * Update los table name * Refactor * Reduce cluster precision * Refactor * Add los db script * Update readme * Add building_data * Update acuity webhook handler
- Loading branch information
Showing
12 changed files
with
212 additions
and
79 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
node_modules/ | ||
functions/ | ||
data/ | ||
building_data/ | ||
.env | ||
.DS_Store | ||
.netlify | ||
.netlify |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* eslint-disable camelcase */ | ||
|
||
exports.shorthands = undefined; | ||
|
||
exports.up = (pgm) => { | ||
pgm.createTable("request_tokens", { | ||
token: { type: "varchar(255)", notNull: true }, | ||
request_id: { type: "integer", references: "requests(id)", notNull: true }, | ||
}); | ||
}; | ||
|
||
exports.down = (pgm) => { | ||
pgm.dropTable("request_tokens"); | ||
}; |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require("dotenv").config(); | ||
const { Pool } = require("pg"); | ||
const url = require("url"); | ||
|
||
createTables().then(() => process.exit(0)); | ||
|
||
async function createTables() { | ||
const pool = createPool(process.env.LOS_DATABASE_URL); | ||
await performQuery(pool, "CREATE EXTENSION IF NOT EXISTS postgis"); | ||
await performQuery(pool, "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal"); | ||
await performQuery(pool, "DROP TABLE IF EXISTS buildings"); | ||
await performQuery( | ||
pool, | ||
"CREATE TABLE IF NOT EXISTS buildings(gid SERIAL PRIMARY KEY, bldg_id varchar(255), bldg_bin varchar(255), geom GEOMETRY('MULTIPOLYGONZ', 2263))" | ||
); | ||
await performQuery( | ||
pool, | ||
"CREATE INDEX IF NOT EXISTS geom_index ON buildings USING GIST (geom)" | ||
); | ||
await performQuery( | ||
pool, | ||
"CREATE INDEX IF NOT EXISTS bin_index ON buildings (bldg_bin)" | ||
); | ||
} | ||
|
||
async function performQuery(pool, text, values) { | ||
const client = await pool.connect(); | ||
const result = await client.query(text, values); | ||
client.release(); | ||
return result.rows; | ||
} | ||
|
||
function createPool(connectionString) { | ||
const params = url.parse(connectionString); | ||
return new Pool({ | ||
connectionString, | ||
ssl: sslOptions(params.hostname), | ||
}); | ||
|
||
// See src/db/index.js | ||
function sslOptions(host) { | ||
if (host === "localhost" || host === "127.0.0.1") return false; | ||
return { | ||
rejectUnauthorized: false, | ||
mode: "require", | ||
}; | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.