Skip to content

use FETCH_HEAD timestamp to avoid excessive background fetching - #3403

Merged
joshaber merged 6 commits into
masterfrom
maybe-not-fetch-when-switching
Nov 30, 2017
Merged

joshaber merged 6 commits into
masterfrom
maybe-not-fetch-when-switching

Conversation

@shiftkey

Copy link
Copy Markdown
Member

Fixes #3329 for those who will switch repositories regularly by using the last fetched timestamp (which git updates using .git/FETCH_HEAD and we track in the app) and ignoring any background fetching for two minutes (chosen arbitrarily).

@shiftkey shiftkey added the ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Nov 22, 2017

@joshaber joshaber left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this logic belongs in the BackgroundFetcher instead of here 🤔

@joshaber joshaber self-assigned this Nov 27, 2017
@shiftkey

Copy link
Copy Markdown
Member Author

I think this logic belongs in the BackgroundFetcher instead of here 🤔

That's where I initially started with this, but the dependency on GitStore for resolving FETCH_HEAD and how AppStore manages these instances lead me to moving it up.

I'll ponder on this some more, maybe there's some moving around we can do here...

@shiftkey shiftkey removed the ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Nov 27, 2017
@joshaber

Copy link
Copy Markdown
Contributor

This is maybe a terrible idea, but it wouldn't bother me to store the last fetched time in localStorage. It means we wouldn't consider fetches from outside the app, but that doesn't seem like a serious downside.

Alternatively, BackgroundFetcher already outsources the actual fetch work. We could similarly outsource the "but should I really fetch?" work.

@shiftkey

Copy link
Copy Markdown
Member Author

We could similarly outsource the "but should I really fetch?" work.

I like this approach. Should be doable.

@shiftkey

Copy link
Copy Markdown
Member Author

🍎

@shiftkey shiftkey added the ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Nov 29, 2017

@joshaber joshaber left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, just one nit about pulling a constant up.

Comment thread app/src/lib/stores/app-store.ts Outdated

const now = new Date()
const timeSinceFetch = now.getTime() - lastFetched.getTime()
const twoMinutes = 2 * 60 * 1000

This comment was marked as spam.

@shiftkey

Copy link
Copy Markdown
Member Author

🐕

@joshaber
joshaber merged commit 015436b into master Nov 30, 2017
@joshaber
joshaber deleted the maybe-not-fetch-when-switching branch November 30, 2017 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review Pull Requests that are ready to be reviewed by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants