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

Improve detection of old questions #6

Open
Azquelt opened this issue Jan 23, 2016 · 2 comments
Open

Improve detection of old questions #6

Azquelt opened this issue Jan 23, 2016 · 2 comments

Comments

@Azquelt
Copy link
Owner

Azquelt commented Jan 23, 2016

Cases to be considered:

Base state, API returns the most recent X questions

  • Q3
  • Q2
  • Q1

New question asked, should see Q4 as new question and send message accordingly

  • Q4
  • Q3
  • Q2

Question Q5 added to list (e.g. because a relevant tag was added), should be considered as a new question:

  • Q3
  • Q5
  • Q2

Question Q2 removed from list (e.g. tag removed or question deleted), should not see Q0 as a new question:

  • Q3
  • Q1
  • Q0
@Azquelt
Copy link
Owner Author

Azquelt commented Jan 23, 2016

Also note that we have occasionally observed that questions appear in the API some time after they are created or updated.

@Azquelt
Copy link
Owner Author

Azquelt commented Jan 23, 2016

Potential approach:

Keep a created date cutoff

  • only ever increases

Keep a list of questions (ID + createdDate) seen since the cutoff

  • add all questions seen to this
  • remove any questions not after the cutoff

Operations:

  • filter old questions (newQuestions, oldState)
  • compute new state (newQuestions, oldState)

ComputeNewState:

  • compute new cutoff as being max(earliest createdDate from the newQuestions, oldState.cutoff)
  • create new list of questions (ID + createdDate) by merging oldState questions with newQuestions
  • remove any questions which were not created after the cutoff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant