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

🏗️ Major Refactor to Remove Label Button Services #1086

Merged

Commits on Oct 9, 2023

  1. Merge branch 'master' of https://github.com/e-mission/e-mission-phone

    …into rewrite-label-btn-services
    JGreenlee committed Oct 9, 2023
    Configuration menu
    Copy the full SHA
    3b5e169 View commit details
    Browse the repository at this point in the history

Commits on Oct 25, 2023

  1. Configuration menu
    Copy the full SHA
    dc28f99 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    8f76ecf View commit details
    Browse the repository at this point in the history
  3. use section summary for getDetectedModes

    e-mission#1014 (comment)
    Confirmed and composite trips have section summaries that are computed on the server. We can use these here instead of using the raw 'sections'.
    Let's also add type definitions for the section summaries.
    JGreenlee committed Oct 25, 2023
    Configuration menu
    Copy the full SHA
    8712380 View commit details
    Browse the repository at this point in the history

Commits on Oct 29, 2023

  1. refactor filters: prep to remove buttons services

    Preparing to remove the buttons services (e-mission#1086), the filter functions need to be tweaked. `user_input` will no longer be stored on the trip object, it will be accessible in the LabelTabContext, not from these functions, so it will be passed in as a second param to these functions as userInputForTrip.
    
    Also, we'll remove the surveyOpt variable from LabelTabContext since (i) it can just be read directly from appConfig and (ii) we don't want to keep more variables than necessary in LabelTabContext to keep it from getting too cluttered.
    
    - the INVALID_EBIKE filter (along with invalidCheck) was removed as it is not used
    - logic for toLabelCheck was written more concisely
    - 'width' is no longer needed on the configuredFilters - this was for the old UI
    JGreenlee committed Oct 29, 2023
    Configuration menu
    Copy the full SHA
    f7716cf View commit details
    Browse the repository at this point in the history

Commits on Oct 30, 2023

  1. map user inputs instead of populating tlEntry objs

    This is a major refactor of how we handle user inputs that removes the need for having separate button services (e-mission#1086)
    
    Instead of populating fields called "userInput" and "additionsList" on trip/place objects, we will store all inputs of each kind in a single object mapping trip/place IDs to inputs. These will be the single source of truth for what inputs are matched to what trips/places and will remove the need for populating/repopulating trips.
    These maps will be accessible in LabelTabContext and read downstream wherever user inputs need to be read.
    
    Specific notes on the changes:
    - In LabelTab, matching inputs now happens not as a part of 'populating' trips/places, but in a useEffect so that whenever timelineMap is updated, timelineLabelMap and timelineNotesMap are also updated.
    - in timelineHelper, we read unprocessedInputs from local and/or server and instead of returning them from 'get' methods, we'll cache them here in timelineHelper and update those caches with 'update' methods.
    - Type definition for UserInput renamed to UnprocessedUserInput to avoid confusion - this only applies to unprocessed inputs and is not necessarily the structure that processed user inputs will have
    - in diaryHelper, getBaseModeOfLabeledTrip was removed since it was basically just a shortcut to getBaseModeByValue with a trip as param instead of its userInput. All usages replaced with getBaseModeByValue
    JGreenlee committed Oct 30, 2023
    Configuration menu
    Copy the full SHA
    4d48aee View commit details
    Browse the repository at this point in the history
  2. remove btn services and survey.ts

    These are not needed since f7716cf and 4d48aee
    JGreenlee committed Oct 30, 2023
    Configuration menu
    Copy the full SHA
    3855a03 View commit details
    Browse the repository at this point in the history
  3. add back verifiability with verifiabilityForTrip()

    As a result of 4d48aee, trips are not populated with the 'verifiability' property. We can handle this with a function call
    JGreenlee committed Oct 30, 2023
    Configuration menu
    Copy the full SHA
    40d3f75 View commit details
    Browse the repository at this point in the history
  4. remove populateCompositeTrips; update types

    The last property on the trip/place objects that differs between phone and server is 'getNextEntry' called from the input matching function.
    We can instead pass 'nextEntry' as a second parameter to the input matching functions.
    
    This allows us to significantly simplify our typings and ensure that 'CompositeTrip' and 'ConfirmedPlace' here will be the same as they are on the server. Hooray!
    
    -- While adjusting inputMatcher, I also renamed 'getUserInputForTrip' to 'getUserInputForTimelineEntry' (i) to be more consistent and (ii) in case we support a 'place user input' in the future
    JGreenlee committed Oct 30, 2023
    Configuration menu
    Copy the full SHA
    49ff385 View commit details
    Browse the repository at this point in the history
  5. TripCard: don't show footer if no notes

    On trips with no notes/additions, an empty <View> was being rendered (causing a 10px gap due to padding)
    If there were no notes, `timelineNotesMap[trip._id.$oid]` would be `undefined`, which does not equal 0.
    We should only show notes if it is defined AND the length is not 0, so we can just say `timelineNotesMap[trip._id.$oid]?.length`.
    JGreenlee committed Oct 30, 2023
    Configuration menu
    Copy the full SHA
    a34c219 View commit details
    Browse the repository at this point in the history
  6. remove unused vars in LabelTab

    Replaced one use of `Logger` with `displayError`. Now we don't need to use these Angular services here anymore. The only Angular service still used in this file is TimelineHelper.
    JGreenlee committed Oct 30, 2023
    Configuration menu
    Copy the full SHA
    c262f6a View commit details
    Browse the repository at this point in the history

Commits on Oct 31, 2023

  1. fix label button showing before appConfig loaded

    Before appConfig is loaded, we we are unsure whether MultilabelButtonGroup or UserInputButton should be shown neither. As long as appConfig is undefined we want to show neither. So a simple if/else is not sufficient here, we should specifically check for the presence of either MULTILABEL or ENKETO
    JGreenlee committed Oct 31, 2023
    Configuration menu
    Copy the full SHA
    9009517 View commit details
    Browse the repository at this point in the history
  2. combine processed+unprocessed survey responses

    In inputMatcher -> mapInputsToTimelineEntries, adds back the logic for handling processed survey response inputs that are already matched to the trip/place on the server. For user_input, we only use it if there is no unprocessed user input (since unprocessed entries will be newer).
    For additions, we have to merge processed+unprocessed and then from this, get the non-deleted, unique entries.
    
    in timelineHelper, when storing unprocessedNotes we should remove duplicates according to their write_ts, not by getUniqueEntries(getNotDeletedCandidates(...)), because we need to retain the "DELETED" entries so they can be matched to any processed entries that they may refer to
    JGreenlee committed Oct 31, 2023
    Configuration menu
    Copy the full SHA
    fb46586 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    af5948b View commit details
    Browse the repository at this point in the history
  4. expand types

    -added type def for ConfirmedPlace
    -create ObjectId instead of repeating `{ $oid: string }`
    -expanded user input typings:
      -- this was tricky because the structure of the user input received from the server differs by key. For labels, we just get a string value for the label chosen. For survey responses, we get a actual raw data entry. For the purpose of typing these, I am differentiating them based on whether the key ends in 'user_input' (used for surveys) or if it ends in 'confirm' (used for labels)
    -use these new typings in LabelTab and inputMatcher
    JGreenlee committed Oct 31, 2023
    Configuration menu
    Copy the full SHA
    d96ff8d View commit details
    Browse the repository at this point in the history
  5. fix diaryHelper.test.ts

    Since 8712380, the getDetectedModes function no longer goes through the sections of a trip and sums up distances to get percentages. We now use cleaned_section_summary and inferred_section_summary which are computed on the server for us. Updating the test to reflect this causes it to pass again.
    JGreenlee committed Oct 31, 2023
    Configuration menu
    Copy the full SHA
    22b80f9 View commit details
    Browse the repository at this point in the history

Commits on Nov 1, 2023

  1. Configuration menu
    Copy the full SHA
    081b142 View commit details
    Browse the repository at this point in the history

Commits on Nov 2, 2023

  1. Merge remote-tracking branch 'upstream/service_rewrite_2023' into rew…

    …rite-label-btn-services
    JGreenlee committed Nov 2, 2023
    Configuration menu
    Copy the full SHA
    956f2d9 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    5110845 View commit details
    Browse the repository at this point in the history

Commits on Nov 3, 2023

  1. remove 'locales' submodule

    This was committed by mistake in 5110845
    JGreenlee committed Nov 3, 2023
    Configuration menu
    Copy the full SHA
    1f952f7 View commit details
    Browse the repository at this point in the history
  2. fix syntax errors and apply prettier

    Prettier was not running on these files because they had syntax errors from bad merge conflicts. Fixes syntax on these and runs Prettier to clean up
    JGreenlee committed Nov 3, 2023
    Configuration menu
    Copy the full SHA
    1b01692 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    5eb8d8f View commit details
    Browse the repository at this point in the history
  4. clean up confirmHelper

    -add labelOptionByValue function to make it easier to lookup a labelOption by a label value; use it in other functions that need to perform this lookup
    -type getFakeEntry, return undefined if falsy input
    -verifiabilityForTrip should only consider 'inferred' true if it has any truthy values; not if all values are undefined
    -inferFinalLabels: if no usable inferences, return empty object rather than object with undefined values
    JGreenlee committed Nov 3, 2023
    Configuration menu
    Copy the full SHA
    24b34ee View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    55c313d View commit details
    Browse the repository at this point in the history

Commits on Nov 10, 2023

  1. Configuration menu
    Copy the full SHA
    a60b1e2 View commit details
    Browse the repository at this point in the history
  2. fix en.json -> "questions"

    Something got jumbled when pulling in upstream changes + resolving conflicts
    JGreenlee committed Nov 10, 2023
    Configuration menu
    Copy the full SHA
    d3e6af2 View commit details
    Browse the repository at this point in the history
  3. remove duplicate 'verifiability' check

    This was also likely due to bad merging from upstream changes
    JGreenlee committed Nov 10, 2023
    Configuration menu
    Copy the full SHA
    69b18cb View commit details
    Browse the repository at this point in the history