Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #51 from igNew/version3
Browse files Browse the repository at this point in the history
Multiple updates from Slingshot into the Version3 branch.
  • Loading branch information
schnuerle authored Feb 21, 2019
2 parents b0cff9f + 1beeb24 commit 515453f
Show file tree
Hide file tree
Showing 18 changed files with 740 additions and 217 deletions.
Binary file modified code/lambda-functions/waze-data-process.zip
Binary file not shown.
44 changes: 38 additions & 6 deletions code/lambda-functions/waze-data-process/src/db/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export async function upsertAlertCommand(alert: entities.Alert): Promise<void> {
report_by_municipality_user,
thumbs_up,
jam_uuid,
datafile_id
datafile_id,
dayofweek
)
VALUES (
$1, -- id
Expand All @@ -81,7 +82,8 @@ export async function upsertAlertCommand(alert: entities.Alert): Promise<void> {
$17, -- report_by_municipality_user
$18, -- thumbs_up
$19, -- jam_uuid
$20 -- datafile_id
$20, -- datafile_id
$21 -- dayofweek
)
ON CONFLICT (id) DO UPDATE SET
uuid=$2,
Expand All @@ -102,7 +104,8 @@ export async function upsertAlertCommand(alert: entities.Alert): Promise<void> {
report_by_municipality_user=$17,
thumbs_up=$18,
jam_uuid=$19,
datafile_id=$20`;
datafile_id=$20,
dayofweek=$21`;
//#endregion

let result = await connectionPool.getPool().query(sql, [
Expand All @@ -126,12 +129,21 @@ export async function upsertAlertCommand(alert: entities.Alert): Promise<void> {
alert.thumbs_up, //thumbs_up
alert.jam_uuid , //jam_uuid
alert.datafile_id, //datafile_id
alert.dayofweek //dayofweek
]);

//nothing currently to alter on the alert object based on SQL return
return;
}

// update geometry for a jam. This uses a function that converst jsonb to geometry
// the function definition is assumed to match the SRID of the column definitions
export async function updateAlertGeometry(id: string) {
const sql = `update waze.alerts set geom_point=waze.location_to_geometry(location) where id=$1`;
let result = await connectionPool.getPool().query(sql, [id]);
return;
}

// upsert a jam record
export async function upsertJamCommand(jam: entities.Jam): Promise<void> {
//for simplicity, we'll always insert and update all fields, since our hash should ensure there aren't unexpected changes
Expand Down Expand Up @@ -159,7 +171,10 @@ export async function upsertJamCommand(jam: entities.Jam): Promise<void> {
line,
datafile_id,
type,
turn_line
turn_line,
ns_direction,
ew_direction,
dayofweek
)
VALUES (
$1, -- id
Expand All @@ -182,7 +197,10 @@ export async function upsertJamCommand(jam: entities.Jam): Promise<void> {
$18, -- line
$19, -- datafile_id
$20, -- type
$21 -- turn_line
$21, -- turn_line
$22, -- ns_direction
$23, -- ew_direction
$24 -- dayofweek
)
ON CONFLICT (id) DO UPDATE SET
uuid=$2,
Expand All @@ -204,7 +222,10 @@ export async function upsertJamCommand(jam: entities.Jam): Promise<void> {
line=$18,
datafile_id=$19,
type=$20,
turn_line=$21`;
turn_line=$21,
ns_direction=$22,
ew_direction=$23,
dayofweek=$24`;
//#endregion

let result = await connectionPool.getPool().query(sql, [
Expand All @@ -229,13 +250,24 @@ export async function upsertJamCommand(jam: entities.Jam): Promise<void> {
jam.datafile_id, //datafile_id
jam.type, //type
jam.turn_line, //turn_line
jam.ns_direction, //ns_direction
jam.ew_direction, //ew_direction
jam.dayofweek //dayofweek
]);

//nothing currently to update on the jam object based on SQL return
return;

}

// update geometry for a jam. This uses a function that converst jsonb to geometry
// the function definition is assumed to match the SRID of the column definitions
export async function updateJamGeometry(id: string) {
const sql = `update waze.jams set geom_line=waze.line_to_geometry(line) where id=$1`;
let result = await connectionPool.getPool().query(sql, [id]);
return;
}

// upsert an irregularity record
export async function upsertIrregularityCommand(irregularity: entities.Irregularity): Promise<void> {
//for simplicity, we'll always insert and update all fields, since our hash should ensure there aren't unexpected changes
Expand Down
4 changes: 4 additions & 0 deletions code/lambda-functions/waze-data-process/src/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class Alert {
thumbs_up: number;
jam_uuid: string;
datafile_id: number;
dayofweek: number;
}

export class Jam {
Expand All @@ -56,6 +57,9 @@ export class Jam {
type: string;
turn_line: string;
datafile_id: number;
ew_direction: string;
ns_direction: string;
dayofweek: number;
}

export class Irregularity {
Expand Down
Loading

0 comments on commit 515453f

Please sign in to comment.