-
Notifications
You must be signed in to change notification settings - Fork 114
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
🎆 Only do BLE matching on the phone for unprocessed BLE Scans #1154
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,11 +29,7 @@ | |
import { displayError, displayErrorMsg, logDebug, logWarn } from '../plugin/logger'; | ||
import { useTheme } from 'react-native-paper'; | ||
import { getPipelineRangeTs } from '../services/commHelper'; | ||
import { | ||
getNotDeletedCandidates, | ||
mapBleScansToTimelineEntries, | ||
mapInputsToTimelineEntries, | ||
} from '../survey/inputMatcher'; | ||
import { getNotDeletedCandidates, mapInputsToTimelineEntries } from '../survey/inputMatcher'; | ||
import { configuredFilters as multilabelConfiguredFilters } from '../survey/multilabel/infinite_scroll_filters'; | ||
import { configuredFilters as enketoConfiguredFilters } from '../survey/enketo/infinite_scroll_filters'; | ||
import LabelTabContext, { | ||
|
@@ -45,6 +41,7 @@ | |
import { readAllCompositeTrips, readUnprocessedTrips } from './timelineHelper'; | ||
import { LabelOptions, MultilabelKey } from '../types/labelTypes'; | ||
import { CompositeTrip, TimelineEntry, TimestampRange, UserInputEntry } from '../types/diaryTypes'; | ||
import { primarySectionForTrip } from './diaryHelper'; | ||
|
||
let showPlaces; | ||
const ONE_DAY = 24 * 60 * 60; // seconds | ||
|
@@ -63,7 +60,6 @@ | |
const [timelineMap, setTimelineMap] = useState<TimelineMap | null>(null); | ||
const [timelineLabelMap, setTimelineLabelMap] = useState<TimelineLabelMap | null>(null); | ||
const [timelineNotesMap, setTimelineNotesMap] = useState<TimelineNotesMap | null>(null); | ||
const [timelineBleMap, setTimelineBleMap] = useState<any>(null); | ||
const [displayedEntries, setDisplayedEntries] = useState<TimelineEntry[] | null>(null); | ||
const [refreshTime, setRefreshTime] = useState<Date | null>(null); | ||
const [isLoading, setIsLoading] = useState<string | false>('replace'); | ||
|
@@ -105,15 +101,8 @@ | |
allEntries, | ||
appConfig, | ||
); | ||
|
||
setTimelineLabelMap(newTimelineLabelMap); | ||
setTimelineNotesMap(newTimelineNotesMap); | ||
|
||
if (appConfig.vehicle_identities?.length) { | ||
const newTimelineBleMap = mapBleScansToTimelineEntries(allEntries, appConfig); | ||
setTimelineBleMap(newTimelineBleMap); | ||
} | ||
|
||
applyFilters(timelineMap, newTimelineLabelMap); | ||
} catch (e) { | ||
displayError(e, t('errors.while-updating-timeline')); | ||
|
@@ -171,7 +160,7 @@ | |
unprocessedNotes = ${JSON.stringify(unprocessedNotes)}`); | ||
if (appConfig.vehicle_identities?.length) { | ||
await updateUnprocessedBleScans({ | ||
start_ts: pipelineRange.start_ts, | ||
start_ts: pipelineRange.end_ts, | ||
end_ts: Date.now() / 1000, | ||
}); | ||
logDebug(`LabelTab: After updating unprocessedBleScans, | ||
|
@@ -301,7 +290,12 @@ | |
.reverse() | ||
.find((trip) => trip.origin_key.includes('trip')) as CompositeTrip; | ||
} | ||
readUnprocessedPromise = readUnprocessedTrips(pipelineRange.end_ts, nowTs, lastProcessedTrip); | ||
readUnprocessedPromise = readUnprocessedTrips( | ||
pipelineRange.end_ts, | ||
nowTs, | ||
appConfig, | ||
lastProcessedTrip, | ||
); | ||
} else { | ||
readUnprocessedPromise = Promise.resolve([]); | ||
} | ||
|
@@ -336,8 +330,8 @@ | |
* @returns Confirmed mode, which could be a vehicle identity as determined by Bluetooth scans, | ||
* or the label option from a user-given 'MODE' label, or undefined if neither exists. | ||
*/ | ||
const confirmedModeFor = (tlEntry: TimelineEntry) => | ||
timelineBleMap?.[tlEntry._id.$oid] || labelFor(tlEntry, 'MODE'); | ||
const confirmedModeFor = (tlEntry: CompositeTrip) => | ||
primarySectionForTrip(tlEntry)?.ble_sensed_mode || labelFor(tlEntry, 'MODE'); | ||
Comment on lines
-339
to
+334
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit, future fix: I think it would be worthwhile for you and Abby to sync up on how this should work across the public dashboard and the phone. The server side data does not have a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, this is not the long term solution. "Confirmed mode" was something temporary I threw together for the alpha. When I first added it, it actually represented the BLE sensed mode OR the labeled mode, depending on what was available. For I do think something like "confirmed mode" will be useful in the app dashboard and for analysis. I'm envisioning future programs that could theoretically use BLE sensing in addition to mode+purpsoe labels – the BLE sensed trips will not need manual user input since we already "confirmed" the mode when we matched it to a beacon. |
||
|
||
function addUserInputToEntry(oid: string, userInput: any, inputType: 'label' | 'note') { | ||
const tlEntry = timelineMap?.get(oid); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to self, this is not an error, this is the performance optimization!