MAPC / massbuilds

Crowdsourcing authoritative info on recent & ongoing developments in Massachusetts.
https://www.massbuilds.com/
2 stars 2 forks source link

Mjz/308 mepa id traffic monitoring #315

Closed mzagaja closed 3 years ago

mzagaja commented 3 years ago

Resolves # 308.

Why is this change necessary?

We want to add MEPA ID and Traffic Count Data fields to the development model.

How does it address the issue?

It does this, along with adding filters, and as a bonus we update our migrations to point to the correct (latest) DB server as well.

mzagaja commented 3 years ago

Can you post the Rails log from the development submission? Specifically the section that looks like:

Started POST "/developments" for ::1 at 2021-03-22 11:16:58 -0400
Processing by DevelopmentsController#create as JSONAPI
  Parameters: {"data"=>{"attributes"=>{"name"=>"Test with MEPA ID", "status"=>"planning", "descr"=>"Test", "prj_url"=>nil, "tagline"=>nil, "nhood"=>nil, "address"=>nil, "state"=>"MA", "zip_code"=>nil, "park_type"=>nil, "parcel_id"=>nil, "municipal"=>nil, "devlper"=>nil, "traffic_count_data"=>"https://www.google.com/", "height"=>nil, "stories"=>nil, "year_compl"=>2030, "prjarea"=>nil, "singfamhu"=>0, "smmultifam"=>0, "lgmultifam"=>0, "unknownhu"=>nil, "hu"=>0, "gqpop"=>nil, "rptdemp"=>nil, "commsf"=>0, "hotelrms"=>0, "onsitepark"=>nil, "total_cost"=>nil, "ret_sqft"=>0, "ofcmd_sqft"=>0, "indmf_sqft"=>0, "whs_sqft"=>0, "rnd_sqft"=>0, "ei_sqft"=>0, "other_sqft"=>0, "hotel_sqft"=>0, "unk_sqft"=>0, "latitude"=>42.365871579965614, "longitude"=>-71.09295709889464, "units_1bd"=>nil, "units_2bd"=>nil, "units_3bd"=>nil, "affrd_unit"=>nil, "aff_u30"=>nil, "aff_30_50"=>nil, "aff_50_80"=>nil, "aff_80p"=>nil, "aff_unknown"=>nil, "publicsqft"=>0, "mepa_id"=>123456, "rdv"=>false, "asofright"=>false, "ovr55"=>false, "clusteros"=>false, "phased"=>false, "stalled"=>false, "headqtrs"=>false, "mixed_use"=>false, "yrcomp_est"=>false, "flag"=>false, "created_at"=>nil, "updated_at"=>nil}, "relationships"=>{"user"=>{"data"=>{"type"=>"users", "id"=>"261"}}}, "type"=>"developments"}}
  User Load (0.5ms)  SELECT  "users".* FROM "users" WHERE "users"."email" = $1 LIMIT $2  [["email", "mzagaja@mapc.org"], ["LIMIT", 1]]
   (0.1ms)  BEGIN
  SQL (0.4ms)  UPDATE "users" SET "current_sign_in_at" = $1, "last_sign_in_at" = $2, "sign_in_count" = $3, "updated_at" = $4 WHERE "users"."id" = $5  [["current_sign_in_at", "2021-03-22 15:16:58.928767"], ["last_sign_in_at", "2021-03-22 15:13:35.452357"], ["sign_in_count", 17465], ["updated_at", "2021-03-22 15:16:58.929240"], ["id", 261]]
   (0.3ms)  COMMIT
   (0.2ms)  BEGIN
  SQL (7.7ms)  INSERT INTO "developments" ("user_id", "rdv", "asofright", "ovr55", "clusteros", "phased", "stalled", "name", "status", "descr", "year_compl", "singfamhu", "smmultifam", "lgmultifam", "hu", "commsf", "hotelrms", "ret_sqft", "ofcmd_sqft", "indmf_sqft", "whs_sqft", "rnd_sqft", "ei_sqft", "other_sqft", "hotel_sqft", "latitude", "longitude", "mixed_use", "point", "created_at", "updated_at", "yrcomp_est", "headqtrs", "publicsqft", "unk_sqft", "mepa_id", "traffic_count_data", "mepa_id_present", "traffic_count_data_present") VALUES ($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) RETURNING "id"  [["user_id", 261], ["rdv", "f"], ["asofright", "f"], ["ovr55", "f"], ["clusteros", "f"], ["phased", "f"], ["stalled", "f"], ["name", "Test with MEPA ID"], ["status", "planning"], ["descr", "Test"], ["year_compl", 2030], ["singfamhu", 0], ["smmultifam", 0], ["lgmultifam", 0], ["hu", 0], ["commsf", 0], ["hotelrms", 0], ["ret_sqft", 0.0], ["ofcmd_sqft", 0.0], ["indmf_sqft", 0.0], ["whs_sqft", 0.0], ["rnd_sqft", 0.0], ["ei_sqft", 0.0], ["other_sqft", 0.0], ["hotel_sqft", 0.0], ["latitude", "42.3658715799656"], ["longitude", "-71.0929570988946"], ["mixed_use", "f"], ["point", "0020000001000010e6c051c5f30254ebbc40452ed4e1433e7a"], ["created_at", "2021-03-22 15:16:58.936568"], ["updated_at", "2021-03-22 15:16:58.936568"], ["yrcomp_est", "f"], ["headqtrs", "f"], ["publicsqft", 0], ["unk_sqft", 0], ["mepa_id", 123456], ["traffic_count_data", "https://www.google.com/"], ["mepa_id_present", "t"], ["traffic_count_data_present", "t"]]
atomtay commented 3 years ago

Admin is working now for me (my best guess is ghosts), but here's the Rails log anyway:

Started POST "/developments" for 127.0.0.1 at 2021-03-22 11:36:48 -0400
Processing by DevelopmentsController#create as JSONAPI
  Parameters: {"data"=>{"attributes"=>{"name"=>"Medfield Test", "status"=>"completed", "descr"=>"ABC 123", "prj_url"=>nil, "tagline"=>nil, "nhood"=>nil, "address"=>nil, "state"=>"MA", "zip_code"=>nil, "park_type"=>nil, "parcel_id"=>nil, "municipal"=>nil, "devlper"=>nil, "traffic_count_data"=>"https://mobility-massdot.hub.arcgis.com", "height"=>nil, "stories"=>nil, "year_compl"=>2020, "prjarea"=>nil, "singfamhu"=>0, "smmultifam"=>0, "lgmultifam"=>0, "unknownhu"=>nil, "hu"=>0, "gqpop"=>0, "rptdemp"=>nil, "commsf"=>1000, "hotelrms"=>0, "onsitepark"=>nil, "total_cost"=>nil, "ret_sqft"=>1000, "ofcmd_sqft"=>0, "indmf_sqft"=>0, "whs_sqft"=>0, "rnd_sqft"=>0, "ei_sqft"=>0, "other_sqft"=>0, "hotel_sqft"=>0, "unk_sqft"=>0, "latitude"=>42.20913337414299, "longitude"=>-71.27948750438239, "units_1bd"=>nil, "units_2bd"=>nil, "units_3bd"=>nil, "affrd_unit"=>0, "aff_u30"=>0, "aff_30_50"=>0, "aff_50_80"=>0, "aff_80p"=>0, "aff_unknown"=>0, "publicsqft"=>0, "mepa_id"=>12345, "rdv"=>false, "asofright"=>false, "ovr55"=>false, "clusteros"=>false, "phased"=>false, "stalled"=>false, "headqtrs"=>false, "mixed_use"=>false, "yrcomp_est"=>false, "flag"=>false, "created_at"=>nil, "updated_at"=>nil}, "relationships"=>{"user"=>{"data"=>{"type"=>"users", "id"=>"594"}}}, "type"=>"developments"}}
User Load (2.2ms)  SELECT  "users".* FROM "users" WHERE "users"."email" = $1 LIMIT $2  [["email", "ataylor@mapc.org"], ["LIMIT", 1]]
   (5.0ms)  BEGIN
  SQL (19.7ms)  UPDATE "users" SET "current_sign_in_at" = $1, "last_sign_in_at" = $2, "sign_in_count" = $3, "updated_at" = $4 WHERE "users"."id" = $5  [["current_sign_in_at", "2021-03-22 15:36:48.347619"], ["last_sign_in_at", "2021-03-22 15:35:03.586558"], ["sign_in_count", 58], ["updated_at", "2021-03-22 15:36:48.353957"], ["id", 594]]
   (9.0ms)  COMMIT
   (0.4ms)  BEGIN
  SQL (17.1ms)  INSERT INTO "developments" ("user_id", "rdv", "asofright", "ovr55", "clusteros", "phased", "stalled", "name", "status", "descr", "year_compl", "singfamhu", "smmultifam", "lgmultifam", "hu", "gqpop", "commsf", "hotelrms", "ret_sqft", "ofcmd_sqft", "indmf_sqft", "whs_sqft", "rnd_sqft", "ei_sqft", "other_sqft", "hotel_sqft", "latitude", "longitude", "mixed_use", "point", "created_at", "updated_at", "yrcomp_est", "affrd_unit", "aff_u30", "aff_30_50", "aff_50_80", "aff_80p", "headqtrs", "publicsqft", "aff_unknown", "unk_sqft", "flag", "mepa_id", "traffic_count_data", "mepa_id_present", "traffic_count_data_present") VALUES ($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) RETURNING "id"  [["user_id", 594], ["rdv", "f"], ["asofright", "f"], ["ovr55", "f"], ["clusteros", "f"], ["phased", "f"], ["stalled", "f"], ["name", "Medfield Test"], ["status", "completed"], ["descr", "ABC 123"], ["year_compl", 2020], ["singfamhu", 0], ["smmultifam", 0], ["lgmultifam", 0], ["hu", 0], ["gqpop", 0], ["commsf", 1000], ["hotelrms", 0], ["ret_sqft", 1000.0], ["ofcmd_sqft", 0.0], ["indmf_sqft", 0.0], ["whs_sqft", 0.0], ["rnd_sqft", 0.0], ["ei_sqft", 0.0], ["other_sqft", 0.0], ["hotel_sqft", 0.0], ["latitude", "42.209133374143"], ["longitude", "-71.2794875043824"], ["mixed_use", "f"], ["point", "0020000001000010e6c051d1e31f8ebda340451ac4e1e53921"], ["created_at", "2021-03-22 15:36:48.400920"], ["updated_at", "2021-03-22 15:36:48.400920"], ["yrcomp_est", "f"], ["affrd_unit", 0], ["aff_u30", 0], ["aff_30_50", 0], ["aff_50_80", 0], ["aff_80p", 0], ["headqtrs", "f"], ["publicsqft", 0], ["aff_unknown", 0], ["unk_sqft", 0], ["flag", "f"], ["mepa_id", 12345], ["traffic_count_data", "https://mobility-massdot.hub.arcgis.com"], ["mepa_id_present", "t"], ["traffic_count_data_present", "t"]]

The municipal user is still getting logged out, even when creating developments in their municipality:

Started POST "/developments" for 127.0.0.1 at 2021-03-22 11:40:05 -0400
Processing by DevelopmentsController#create as JSONAPI
  Parameters: {"data"=>{"attributes"=>{"name"=>"Cambridge Test", "status"=>"completed", "descr"=>"123 ABC", "prj_url"=>nil, "tagline"=>nil, "nhood"=>nil, "address"=>nil, "state"=>"MA", "zip_code"=>nil, "park_type"=>nil, "parcel_id"=>nil, "municipal"=>nil, "devlper"=>nil, "traffic_count_data"=>"https://mobility-massdot.hub.arcgis.com", "height"=>nil, "stories"=>nil, "year_compl"=>2020, "prjarea"=>nil, "singfamhu"=>0, "smmultifam"=>0, "lgmultifam"=>0, "unknownhu"=>nil, "hu"=>0, "gqpop"=>0, "rptdemp"=>nil, "commsf"=>10, "hotelrms"=>0, "onsitepark"=>nil, "total_cost"=>nil, "ret_sqft"=>10, "ofcmd_sqft"=>0, "indmf_sqft"=>0, "whs_sqft"=>0, "rnd_sqft"=>0, "ei_sqft"=>0, "other_sqft"=>0, "hotel_sqft"=>0, "unk_sqft"=>0, "latitude"=>42.358001554536344, "longitude"=>-71.11219464318543, "units_1bd"=>nil, "units_2bd"=>nil, "units_3bd"=>nil, "affrd_unit"=>0, "aff_u30"=>0, "aff_30_50"=>0, "aff_50_80"=>0, "aff_80p"=>0, "aff_unknown"=>0, "publicsqft"=>0, "mepa_id"=>123456, "rdv"=>false, "asofright"=>false, "ovr55"=>false, "clusteros"=>false, "phased"=>false, "stalled"=>false, "headqtrs"=>false, "mixed_use"=>false, "yrcomp_est"=>false, "flag"=>false, "created_at"=>nil, "updated_at"=>nil}, "relationships"=>{"user"=>{"data"=>{"type"=>"users", "id"=>"599"}}}, "type"=>"developments"}}
  User Load (1.0ms)  SELECT  "users".* FROM "users" WHERE "users"."email" = $1 LIMIT $2  [["email", "ataylor+test@mapc.org"], ["LIMIT", 1]]
   (1.6ms)  BEGIN
  SQL (36.1ms)  UPDATE "users" SET "current_sign_in_at" = $1, "last_sign_in_at" = $2, "sign_in_count" = $3, "updated_at" = $4 WHERE "users"."id" = $5  [["current_sign_in_at", "2021-03-22 15:40:05.763756"], ["last_sign_in_at", "2021-03-22 15:37:41.207462"], ["sign_in_count", 48], ["updated_at", "2021-03-22 15:40:05.766880"], ["id", 599]]
   (7.4ms)  COMMIT
Completed 401 Unauthorized in 433ms (ActiveRecord: 46.1ms)
mzagaja commented 3 years ago

The logout for municipal users was resolved in #314, but this branch wasn't rebased on it yet. I just did that, so try again.

atomtay commented 3 years ago

Ahh, yes that did the trick. Not sure what was going on on my end for the initial admin problem (perhaps somewhere between keyboard and chair) but everything creates and filters as expected now. Ready to merge!