Visual-Communications / fair-housing-pledge

https://fairhousingpledge.com/
0 stars 0 forks source link

Pledge CSV results `courseCompleted` field #62

Closed paulshryock closed 4 years ago

paulshryock commented 4 years ago

Hey @Esemplaret1, this is the line where the pledge results CSV headers are selected. I did already add courseCompleted in the past, so that should be including that header in the CSV that gets downloaded. If it's not showing up, I can dig in and debug tonight.

https://github.com/Visual-Communications/fair-housing-pledge/blob/b97c04d0dcc34478256c2176ef7095ee7eedef06/modules/pledge-results.js#L11

Esemplaret1 commented 4 years ago

Understood! It is not showing up. I've started testing the keys array. Adding new elements did nothing. However, I could delete elements and the changes would be reflected immediately.

That seems to me like it's a problem with the source we're getting the pledge data from (or with some middleman between that and us).

http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail Virus-free. www.avg.com http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Wed, Jul 15, 2020 at 3:08 PM Paul Shryock notifications@github.com wrote:

Hey @Esemplaret1 https://github.com/Esemplaret1, this is the line where the pledge results CSV headers are selected. I did already add courseCompleted in the past, so that should be including that header in the CSV that gets downloaded. If it's not showing up, I can dig in and debug tonight.

https://github.com/Visual-Communications/fair-housing-pledge/blob/b97c04d0dcc34478256c2176ef7095ee7eedef06/modules/pledge-results.js#L11

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Visual-Communications/fair-housing-pledge/issues/62, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIK53GNTH3L2ZYGTUTR7OLDR3X5DDANCNFSM4O22IJOQ .

--

Respectfully, Thomas Esemplare

paulshryock commented 4 years ago

That seems to me like it's a problem with the source we're getting the pledge data from

@Esemplaret1, in order to verify what we're getting back, I've set these local environment variables in my .env file:

And in a terminal window, ran npm run serve:server to fire up the local API. From there, I logged in by sending a POST request to http://localhost:3000/api/auth with a JSON body like this (with the email and password filled in, which I got from .env):

{
  "email": "",
  "password": ""
}

Then I sent a GET request to http://localhost:3000/api/pledges, which returns an array of objects. I searched the body of the response for courseCompleted and found that some of the pledge objects do indeed have that value, like this one:

{
    "_id": "5f08bb61414013002310755e",
    "firstName": "Holly",
    "lastName": "Rasmussen",
    "email": "holly@hollyrasmussen.com",
    "state": "CO",
    "brand": "SIR",
    "company": "LIV Sotheby's International Realty",
    "event": "N/A",
    "agreeToTerms": "on",
    "courseCompleted": "true",
    "created_at": "2020-07-10T19:02:57.595Z",
    "__v": 0
}

So that tells me that:

  1. There are at least some results in the database which have courseCompleted values
  2. The API is returning those results

So I still think the problem lies with the Pledge Results module.

I'm going to try manually updating all of the pledge results in the database so that those without a courseCompleted value get a value of N/A. I think once all the objects have that value, the problem might fix itself.

paulshryock commented 4 years ago

@Esemplaret1, the above solution worked. I manually added courseCompleted: 'N/A' to all pledge results which didn't already have that property. Now running npm run pledge:results returns that header as it should. I guess every database record has to share the same set of headers that we're asking for in the keys array.

paulshryock commented 4 years ago

I'm closing this out. Feel free to reopen and tag me if you still have any issues with this.