Recsys: improve data stashing frequency
## Issue The 15s saving interval (hijacking the position-saving code) is too far apart, causing rescys data to be lost when tab is closed/refreshed. ## Change While I think it is fine to save to redux every second, it is still best to avoid that since a state change will always cause the map-to-props to evaluate. Chose 5s as the interval and moved away from the position-saving code (the recsys videojs plugin is a better choice to handle this). Also save it on `t=1` so that at least we know it played prior to the tab refreshing/closing. ## Considered - Didn't want to do `beforeunload` again since it is unreliable and a pain to test in mobile.
This commit is contained in:
parent
8aa831fe49
commit
7ea73c3f1b
2 changed files with 4 additions and 2 deletions
|
@ -129,7 +129,11 @@ class RecsysPlugin extends Component {
|
|||
if (this.watchedDuration.lastTimestamp !== curTimeSec && !this.inPause) {
|
||||
this.watchedDuration.total += 1;
|
||||
this.watchedDuration.lastTimestamp = curTimeSec;
|
||||
|
||||
RecSys.updateRecsysEntry(this.options_.videoId, 'totalPlayTime', this.watchedDuration.total);
|
||||
if (this.watchedDuration.total === 1 || this.watchedDuration.total % 5 === 0) {
|
||||
RecSys.saveEntries();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ import { formatLbryUrlForWeb, generateListSearchUrlParams } from 'util/url';
|
|||
import useInterval from 'effects/use-interval';
|
||||
import { lastBandwidthSelector } from './internal/plugins/videojs-http-streaming--override/playlist-selectors';
|
||||
import { platform } from 'util/platform';
|
||||
import RecSys from 'recsys';
|
||||
|
||||
// const PLAY_TIMEOUT_ERROR = 'play_timeout_error';
|
||||
// const PLAY_TIMEOUT_LIMIT = 2000;
|
||||
|
@ -179,7 +178,6 @@ function VideoViewer(props: Props) {
|
|||
|
||||
useInterval(
|
||||
() => {
|
||||
RecSys.saveEntries();
|
||||
if (playerRef.current && isPlaying && !isLivestreamClaim) {
|
||||
handlePosition(playerRef.current);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue