File tree Expand file tree Collapse file tree 6 files changed +64
-24
lines changed
Expand file tree Collapse file tree 6 files changed +64
-24
lines changed Original file line number Diff line number Diff line change 11import "cross-fetch/polyfill" ;
22
3- import { cartoAccount } from "../constants/config" ;
3+ import { cartoAPIv3BaseURL , cartoApiKey } from "../constants/config" ;
44import { rentStabilizedBblSql } from "../utils/sql" ;
55import * as types from "../constants/actionTypes" ;
66
@@ -23,11 +23,21 @@ export const rentStabilizedReset = () => ({
2323} ) ;
2424
2525export const fetchRentStabilized = ( bbl ) => ( dispatch ) => {
26+ const headers = new Headers ( ) ;
27+ headers . append ( "Authorization" , `Bearer ${ cartoApiKey } ` ) ;
28+
29+ const requestOptions = {
30+ method : "GET" ,
31+ headers : headers ,
32+ redirect : "follow" ,
33+ } ;
34+
2635 dispatch ( rentStabilizedRequest ( ) ) ;
2736 return fetch (
28- `https:// ${ cartoAccount } .cartodb.com/api/v2/ sql?q=${ window . encodeURIComponent (
37+ `${ cartoAPIv3BaseURL } /v3/ sql/carto_dw/query ?q=${ window . encodeURIComponent (
2938 rentStabilizedBblSql ( bbl )
30- ) } `
39+ ) } `,
40+ requestOptions
3141 )
3242 . then ( ( res ) => {
3343 if ( res . ok ) {
Original file line number Diff line number Diff line change 11import "cross-fetch/polyfill" ;
22import * as types from "../constants/actionTypes" ;
3- import { cartoAccount } from "../constants/config" ;
3+ import { cartoApiKey , cartoAPIv3BaseURL } from "../constants/config" ;
44import { tenantsRightsGroupsSql } from "../utils/sql" ;
55
66export const tenantsRightsGroupsRequest = ( ) => ( {
@@ -22,11 +22,21 @@ export const tenantsRightsGroupsReset = () => ({
2222} ) ;
2323
2424export const fetchTenantsRightsGroups = ( { lon, lat } ) => ( dispatch ) => {
25+ const headers = new Headers ( ) ;
26+ headers . append ( "Authorization" , `Bearer ${ cartoApiKey } ` ) ;
27+
28+ const requestOptions = {
29+ method : "GET" ,
30+ headers : headers ,
31+ redirect : "follow" ,
32+ } ;
33+
2534 dispatch ( tenantsRightsGroupsRequest ( ) ) ;
2635 return fetch (
27- `https:// ${ cartoAccount } .cartodb.com/api/v2/ sql?q=${ window . encodeURIComponent (
36+ `${ cartoAPIv3BaseURL } /v3/ sql/carto_dw/query ?q=${ window . encodeURIComponent (
2837 tenantsRightsGroupsSql ( { lon, lat } )
29- ) } `
38+ ) } `,
39+ requestOptions
3040 )
3141 . then ( ( res ) => {
3242 if ( res . ok ) {
Original file line number Diff line number Diff line change @@ -23,7 +23,11 @@ export class VerifyRentStabilized extends Component {
2323 }
2424
2525 updateMessage ( ) {
26- if ( this . match && this . match . total_rows > 0 ) {
26+ if (
27+ this . match &&
28+ Array . isArray ( this . match . rows ) &&
29+ this . match . rows . length
30+ ) {
2731 this . msgYes . classList . remove ( "hidden" ) ;
2832 this . msgNo . classList . add ( "hidden" ) ;
2933 logAddressRS ( this . match . rows [ 0 ] . bbl ) ;
Original file line number Diff line number Diff line change 22export const cartoAccount = "chenrick" ;
33export const rentStabilizedTable = "mappluto_likely_rs_2020_v8" ;
44export const geosearchApiVersion = "v2" ;
5+
6+ export const cartoAPIv3BaseURL = "https://gcp-us-east1.api.carto.com" ;
7+ export const cartoV3RentStabilizedTableName =
8+ "shared.mappluto_likely_rs_2020_v8" ;
9+ export const cartoV3TenantsRightsServiceAreasTable =
10+ "shared.nyc_tenants_rights_service_areas" ;
11+
12+ // NOTE: this API key is restricted for use on the domain https://amirentstabilized.com
13+ export const cartoApiKey =
14+ "eyJhbGciOiJIUzI1NiJ9.eyJhIjoiYWNfd3cwaDFiczgiLCJqdGkiOiIyOTVmZGRkNiJ9.w6GC-oesQEl5HerTbTlZWxFb8-c8iX7F0NAG9pCunu0" ;
Original file line number Diff line number Diff line change 1- import { rentStabilizedTable } from "../constants/config" ;
1+ import {
2+ rentStabilizedTable ,
3+ cartoV3RentStabilizedTableName ,
4+ cartoV3TenantsRightsServiceAreasTable ,
5+ } from "../constants/config" ;
26
37export const rentStabilizedBblSql = ( bbl ) =>
4- `SELECT bbl FROM ${ rentStabilizedTable } WHERE bbl = ${ bbl } ` ;
8+ `SELECT bbl FROM ${ cartoV3RentStabilizedTableName } WHERE bbl = ${ bbl } ` ;
59
610export const mapsApiSql = ( ) =>
711 `SELECT the_geom_webmercator FROM ${ rentStabilizedTable } ` ;
812
913export const tenantsRightsGroupsSql = ( { lon, lat } ) =>
10- `SELECT
11- name,
12- full_address,
13- email,
14- phone,
15- description,
16- service_area,
17- website_url
18- FROM nyc_tenants_rights_service_areas
14+ `SELECT
15+ name,
16+ full_address,
17+ email,
18+ phone,
19+ description,
20+ service_area,
21+ website_url
22+ FROM ${ cartoV3TenantsRightsServiceAreasTable }
1923 WHERE ST_Contains(
20- the_geom,
21- ST_GeomFromText(
22- 'POINT(' || ${ lon } || ' ' || ${ lat } || ')',
23- 4326
24+ geom,
25+ ST_GeogFromText(
26+ 'POINT(' || ${ lon } || ' ' || ${ lat } || ')'
2427 )
2528 )` ;
Original file line number Diff line number Diff line change 11import * as sql from "./sql" ;
2- import { rentStabilizedTable } from "../constants/config" ;
2+ import {
3+ rentStabilizedTable ,
4+ cartoV3RentStabilizedTableName ,
5+ } from "../constants/config" ;
36
47describe ( "utils/sql" , ( ) => {
58 test ( "rentStabilizedBblSql" , ( ) => {
69 const result = sql . rentStabilizedBblSql ( "999999999" ) ;
710 expect ( result ) . toBe (
8- `SELECT bbl FROM ${ rentStabilizedTable } WHERE bbl = 999999999`
11+ `SELECT bbl FROM ${ cartoV3RentStabilizedTableName } WHERE bbl = 999999999`
912 ) ;
1013 } ) ;
1114
You can’t perform that action at this time.
0 commit comments