Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialize JSON in the trips table #69

Closed
shankari opened this issue Aug 19, 2021 · 2 comments · Fixed by #71
Closed

Serialize JSON in the trips table #69

shankari opened this issue Aug 19, 2021 · 2 comments · Fixed by #71

Comments

@shankari
Copy link
Collaborator

shankari commented Aug 19, 2021

As part of the auto-labeling functionality, we added the set of automatically inferred labels to each confirmed trip object. These labels are a JSON dict [{labels: {mode_confirm: X, replace_confirm: Y}, p: <probability>}], similar to

[{'labels': {'mode_confirm': 'bike',
   'purpose_confirm': 'exercise',
   'replaced_mode': 'shared_ride'},
  'p': 0.5},
 {'labels': {'mode_confirm': 'bike',
   'purpose_confirm': 'home',
   'replaced_mode': 'shared_ride'},
  'p': 0.5}]

These show up automatically in the data table, but because this is a JSON array, they show up as [(object Object), (object Object)] (see screenshot). Would it be possible to JSON.serialize this field so the deployer can get a sense of what the trip might be even if the user hasn't labeled it? I think @allenmichael099 had an example of applying a javascript transform to a column (for the bike checkinout table).

image001

@asiripanich
Copy link
Owner

Sure, I can test this once the feature is on the main branch.

@shankari
Copy link
Collaborator Author

The feature is in main now
e-mission/e-mission-server#829

There is a new release
https://github.com/e-mission/e-mission-server/releases/tag/v3.0.0

a new basic docker image
https://hub.docker.com/repository/docker/emission/e-mission-server

I still haven't updated the crontab
https://github.com/e-mission/e-mission-docker/blob/master/examples/em-server-multi-tier-cronjob/analysis/crontab
with the new job (sorry, stuck on my work laptop) but should be able to update it early next week.

shankari added a commit to shankari/emdash that referenced this issue Sep 14, 2021
This fixes asiripanich#69

It basically changes the rendering for the inferred trips table to JSON stringify the array,
similar to asiripanich@eb7921f1

This change works (see screenshots).
However, it has some hacks that should be cleaned up by somebody with more R knowledge than me.

- Multiple copies of `datatable_options`

The current codebase has two identical copies of `datatable_options`
https://github.com/asiripanich/emdash/blob/5334c9229febaddaa234a3d1adc62f8f90547a90/R/app_server.R#L167
and
https://github.com/asiripanich/emdash/blob/5334c9229febaddaa234a3d1adc62f8f90547a90/R/app_server.R#L195

To be consistent with the existing codebase, I have created a third copy for the trips object.
In the long-term, we need to unify all of these to ensure DRY

- Hardcoded column for `inferred_trips`

The `inferred_trips` column number is currently hard-coded to 5. This is because, due to removed columns before display,

```
inferred_label_index <- which(names(data_geogr$trips) == "inferred_labels")
```
returns 17.

We need to find the index in the list of _displayed_ columns, but I don't
understand R well enough to understand where and how to make that change.

@asiripanich, could you clean up the hacks, or do you want to merge first?
asiripanich added a commit that referenced this issue Sep 23, 2021
…data_sf` argument. This change is required to remove `inferred_label` (see #69) from the map data which is a spatial feature object.
asiripanich added a commit that referenced this issue Sep 23, 2021
- Display the inferred labels correctly, See #69. (Thanks @shankari!)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants