ODOT-PTS / TNExT

a web-based software tool developed for the visualization, analysis, and reporting of regional and statewide transit networks in the state of Oregon
15 stars 4 forks source link

UI, allow end user to turn on/off arbitrary sets of agencies. #13

Closed ed-g closed 6 years ago

ed-g commented 7 years ago

Add capacity at UI for end user to turn on/off arbitrary sets of agencies. When an agency is turned off it would not be reflected in any reporting or mapping. An example of a use of this functionality would be for ODOT to turn on all agencies that receive 5311 funding and run reports … like the statewide report. Adding this functionality in combination with the import UI, gives us most of the capacity of the playground. It looks like this class of functionality is currently implemented pre-database build in the import UI, is it practical to use queries to achieve same result, without an extended db build process?

ODOT-RPTD-mb commented 7 years ago

Will require extensive testing, since this will touch most or all queries.

ed-g commented 7 years ago

When agencies are "turned off" for reporting purposes is it OK if they are turned off for every user of the tool at that time?

If so then one possibility is to create a filtered version of each table and run queries on those -- the query text would not need to change only the table it is querying against.

If we want each user to have their own "view" of the data a similar process is possible but a little more work since we'd need to associate a set of tables per user/session.

ed-g commented 7 years ago

@srinivas13794 or @BenFields724 would you be able to create a javascript user interface to "turn off" agencies in the main page, and that sends that list to a Java server page?

If there is a Java server page that knows which agencies should be currently turned off or on, I can create the database backend to actually turn them off or on.

ODOT-RPTD-mb commented 7 years ago

@ed-g @srinivas13794 @BenFields724 Each user should have their own view of the data.

ed-g commented 7 years ago

@srinivas13794 @BenFields724 how are users tracked within java? Is there a JSP session ID or similar?

ed-g commented 7 years ago

I propose the word "hidden" for agencies that are loaded, but which not included in queries for a particular user.

I think we want the following table:

user_hidden_gtfs_agencies (
   jsessionid text not null, 
   agency_id text not null,
   hidden_date timestamptz not null,
   primary key (jsessionid, agency_id),
   foreign key (agency_id) references gtfs_agencies(id)
        on delete cascade on update cascade
)
jsessionid agency_id hidden_date
9DB0B7B7BEA8F7BCFDDE4A12E52858A3 1 2017-09-18 17:41:15.551965+00
9DB0B7B7BEA8F7BCFDDE4A12E52858A3 184 2017-09-18 17:41:15.551965+00
9DB0B7B7BEA8F7BCFDDE4A12E528xxyy 4 2017-09-18 13:41:35.139607+00

user_hidden_gtfs_agencies should expire after 1 day, so that the table does not fill up with old per-session data. Or maybe we keep it around for a week so that we can manually test "older" queries without having to manually re-select the agency hidden list during testing.

We could also create a java_session table and add a foreign key (jessionid) refereneces java_sessions (jsessionid) table etc. but that seems overkill.

Then any query which looks at gtfs_agencies should also include the JSESSIONID cookie, for an anti-join.

-- Check to see if any agencies should be hidden.
LEFT JOIN user_hidden_gtfs_agencies
  ON ( jsession_id = $jsession_id_from_java AND agency_id = gtfs_agencies.id)
....
-- Following clause, means there is no match against user_hidden_gtfs_agencies.
-- In other words, if an agency is not hidden for our current JSESSIONID, include it.
WHERE user_hidden_gtfs_agencies.agency_id == NULL
srinivas13794 commented 7 years ago

@ed-g I have been working on a javascript interface to the functionality you have mentioned.I will push the code and let you know once I have finished it.Again for this task too if we could discuss it briefly over a conference call it would be helpful.

ed-g commented 7 years ago

This is notes from the call. If you can get some list of "hidden" agency id's to java, I can update the table, and then modify a few queries to test the process.

Then if those test queries work we can modify the rest of the queries to be compatible with this way of hiding agencies.

ed-g commented 7 years ago

@srinivas13794 @BenFields724 any updates on this?

srinivas13794 commented 7 years ago

I have pushed a version of this interface onto your development server.I still need to make a few changes.

On Monday, September 25, 2017, Ed Groth notifications@github.com wrote:

@srinivas13794 https://github.com/srinivas13794 @BenFields724 https://github.com/benfields724 any updates on this?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pouyalireza/TNAST_MAVEN/issues/13#issuecomment-331968478, or mute the thread https://github.com/notifications/unsubscribe-auth/ARcwCPMYGw24zICRPjKfrVR55BkQIK-Nks5sl-66gaJpZM4O63fH .

ed-g commented 7 years ago

Is this under the "FS" button, on the main page? http://tna.trilliumtransit.com:8080/?&n=--&dbindex=10

srinivas13794 commented 7 years ago

Yes.

On Mon, Sep 25, 2017 at 12:06 PM, Ed Groth notifications@github.com wrote:

Is this under the "FS" button?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pouyalireza/TNAST_MAVEN/issues/13#issuecomment-331981492, or mute the thread https://github.com/notifications/unsubscribe-auth/ARcwCF197lkpuC_HtCS-2-2-M0Pskpccks5sl_m_gaJpZM4O63fH .

srinivas13794 commented 7 years ago

@ed-g As I mentioned yesterday I have added a basic interface for user selection of agencies that can be accessed by clicking on the FS button.I have programmed it in such a way that the agencyid's are sent to the backend.This is done in the /feedselect path under the queries.java file.I have also added a Print statement that prints out the agencyid's it should show up on your logs.

ed-g commented 6 years ago

Tie into back end such that java/sql side "knows" which agencies the current user has selected. 4 hours.

Design a way to include this information on the sql side in a way that is both performant and easy to join against. 4-6 hours.

Add the join to every query. Depends on the method chosen. 20 minutes to 1 hour per query depending on complexity.

ODOT-RPTD-mb commented 6 years ago

@irees @drewda @PPaulsonOregonDOT It should be relatively easy for user to understand which agencies are active/inactive. Indication of active agencies should be part of report metadata file.

Let's experiment first with the "Statewide Extended Report".

irees commented 6 years ago

@ODOT-RPTD-mb @PPaulsonOregonDOT @drewda

I have an initial implementation and a demo on one report. I used the Transit Agencies Summary Report because it clearly shows the results of the selection. You can select the agencies with the "Agencies" button in the top bar.

http://tna.trilliumtransit.com:8090/TNAtoolAPI-Webapp/AgenSReport.html?&dbindex=12&popYear=2010

I used an approach very similar to what @ed-g sketched out above. There is a new user_selected_agencies table, where each user can set their list of visible agencies, editable using a widget based on the design of the main map agency selector. The results are sent to the /setHiddenAgencies endpoint. The /Agencyget endpoint now also returns the visibility of each agency.

This will be relatively easy to add to the rest of the queries, because it's a drop-in replacement for the existing query from gtfs_selected_feeds, which is already present most places, e.g.:

with aids as (select distinct agency_id as aid from gtfs_selected_feeds where username=?)

->

with aids as (SELECT a.id AS aid FROM gtfs_agencies AS a LEFT OUTER JOIN user_selected_agencies AS b ON (b.username = ? AND a.id = b.agency_id) WHERE b.hidden IS NOT true ORDER BY a.defaultid)

Let me know if this design works well and I'll start rolling it out to other queries.

Current limitations: Everyone is using the admin user, but this will be replaced with unique sessions in the next update. Also I will improve the agency picker dialog placement and scrolling, and add buttons to "select all / unselect all".

PPaulsonOregonDOT commented 6 years ago

@irees I tested this functionality this morning, and it appears to be working. It appears the application reloads after the selection of the agencies, and I want to make sure that this is expected behavior as well. Given that behavior, it might be useful at a later date to have the active agencies reflected in the Oregon Transit Agencies list(in a similar fashion to how agencies with expired feeds are displayed) so that it can be used as reference for which agencies are currently active in the tabular reports.

I believe this data is already accessible under the FS tab, but seeing all of the feeds that are not being used by the tool (expired + selection) would make QA/QC of the tool data more intuitive and less prone to human error.

irees commented 6 years ago

@PPaulsonOregonDOT

OK. Yes, it reloads the current page, since changing the selection will change the report output. In this regard it works similarly to changing the database selector or the population year selector. I could omit this behavior and require a manual "submit" action.

It will be pretty easy to change the style of the selector. That can continue to be done now or in the future, so I will start adding the agency filtering and widgets to more reports today.