InterActionNGO / NGO-admin

Back end for NGO Aid Map
GNU Affero General Public License v3.0
2 stars 0 forks source link

[Humanitarian Updates] Update the front end CSV downloads to include new fields #65

Open btornes opened 6 years ago

btornes commented 6 years ago

The existing API output will be updated to include new fields.

Can see the options to download a CSV here, toward the top before the project list starts: http://ngoaidmap.staging.vigetx.com/organizations/83?

btornes commented 6 years ago

@dce Is it clear what the fields are that will be needed in the CSV? Or is that something we need further clarification on?

RBFraxinus commented 6 years ago

@btornes @dce for now, we just need one additional field in the CSV: the humanitarian (boolean) attribute

btornes commented 6 years ago

@RBFraxinus The CSV file was updated, but we saw it was unexpectedly failing on Staging.

David did some digging and it looks like the CSV download error may be a result of this commit from May: https://github.com/InterActionNGO/ngoaidmap/commit/4694fd0648fe72321ec4c68f783a338010d05f39#diff-091778d5c1679dbdc51b6db971f68d22R196. The CSV downloads are working on production, but because CSV export results are cached, it's possible the error was not introduced there if the cache was never cleared.

Curious if you have any thoughts on this? Or if you noticed any CSV issues after that commit?

RBFraxinus commented 6 years ago

@btornes it looks like any error you are seeing on staging is isolated there. i've created a test branch copy of master and merged @dce 's humanitarian-scope branch and i'm not getting any CSV errors, and all the fields reflect the latest changes. Also, there aren't errors clicking on projects on home page like i noticed on the staging site. Not sure what's going on there because I can't see the error details, but i'm not getting them on my local pull of the scopes branch.

dce commented 6 years ago

Hi @RBFraxinus,

As far as I can see, the issues with the CSV and the project detail view (the page you're taken to after clicking a project from the homepage) have the same root cause. The geolocation readable_path method is commented out:

https://github.com/InterActionNGO/ngoaidmap/blob/master/app/models/geolocation.rb#L92-L94

The Project CSV renderer tries to call readable_path here:

https://github.com/InterActionNGO/ngoaidmap/blob/master/app/models/project.rb#L210

The Project detail page calls it here:

https://github.com/InterActionNGO/ngoaidmap/blob/master/app/views/projects/show.html.erb#L63

Not sure why you aren't seeing errors in other environments -- maybe projects don't have geolocations? Regardless, I'm reasonably certain that readable_path being commented out is the root of both of these issues.

David

RBFraxinus commented 6 years ago

Hi @dce , the readable path method was replaced with a geolocation attribute for performance reasons a bit ago. Are the migrations for both repos (back and front) current on staging? If they're not, that would also explain a readable_path error on staging, but not on my local or production.

Rob

dce commented 6 years ago

Ah, I was told not to run the NGO-admin migrations, just the ngoaidmap ones. I can see the migration that would fix the issue -- will try running it now.

RBFraxinus commented 6 years ago

No worries. It's confusing, as the project was split into two several years ago, and have diverged, but still share quite a bit of redundant and conflicting code.

I'm not entirely confidant in my ability to restore order by refactoring, and I haven't had the time to besides... :(

dce commented 6 years ago

I tried running migrations from the NGO-admin app, but the server isn't configured as a database server in the staging config file:

https://github.com/InterActionNGO/NGO-admin/blob/master/config/deploy/staging.rb

I can change the staging config file, but I'm a little worried what will happen if we run all the migrations in NGO-admin against the staging DB. I can give it a shot if you think it's the right approach though.

RBFraxinus commented 6 years ago

@dce i just took a look, and I think i have a solution. Copy over the last 7 migrations (all dating from 2017) from ngo-admin into ngoaidmap. There's 3 duplicates, so skip or overwrite as you like. Then run migrations on ngoaidmap.

When I got set up last year, I don't remember getting a warning about avoiding the ngo-admin migrations. Might explain why i had a headache setting it up, but i digress. By moving over those 2017 ngo-admin migrations, the ngoaidmap repo should be totally self-contained on migrations. And from now on, i'll avoid adding migrations to the ngo-admin repo.

dce commented 6 years ago

@RBFraxinus copied three commits over from the admin repo in this commit: https://github.com/InterActionNGO/ngoaidmap/commit/928825f535cc2d4b5e5df12202780d309c4d6556. I skipped over all the duplicates plus this one:

https://github.com/InterActionNGO/NGO-admin/blob/master/db/migrate/20170404204021_reset_organization_id_to_id.rb

The issues on staging seem to be resolved. Thanks!

RBFraxinus commented 6 years ago

:+1: