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
Schedule deletion of items older than 30 days #4451
base: feature/cbarreiro/autocomplete/clear-on-fire-button
Are you sure you want to change the base?
Schedule deletion of items older than 30 days #4451
Conversation
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @CrisBarreiro and the rest of your teammates on Graphite |
172b303
to
c391a17
Compare
e113df0
to
689cfdd
Compare
c391a17
to
5ad8558
Compare
689cfdd
to
851d3bd
Compare
5ad8558
to
17efc3b
Compare
851d3bd
to
f4c160e
Compare
17efc3b
to
34610cf
Compare
f4c160e
to
e86e3ed
Compare
34610cf
to
1179474
Compare
e86e3ed
to
23c2fee
Compare
1179474
to
137874e
Compare
23c2fee
to
00576a1
Compare
137874e
to
28eed47
Compare
2ecd8e8
to
daa8627
Compare
28eed47
to
f43ecc1
Compare
daa8627
to
9a51eac
Compare
f43ecc1
to
5418fd5
Compare
9a51eac
to
c2e3c41
Compare
5418fd5
to
5a21ae9
Compare
c2e3c41
to
2a8e5bc
Compare
5a21ae9
to
67be27a
Compare
2a8e5bc
to
4e9c30b
Compare
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.
thanks @CrisBarreiro , leaving you some comments here as well.
|
||
@Test | ||
fun whenDoWorkThenCallCleanOldEntriesAndReturnSuccess() { | ||
appCoroutineScope.launch { |
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.
add dispatcher.io
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.
Genuine question, does it matter for a test?
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.
Missed it was a test 😅. doesn't matter then
@@ -36,6 +36,8 @@ interface HistoryRepository { | |||
) | |||
|
|||
suspend fun clearHistory() | |||
|
|||
suspend fun clearEntriesOlderThan(minusDays: LocalDateTime) |
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.
should we rename minusDays
to something like time
or timestamp
?
suspend fun deleteEntriesOlderThan(dateTime: LocalDateTime) { | ||
val timestamp = DatabaseDateFormatter.timestamp(dateTime) | ||
|
||
deleteOldVisitsByTimestamp(timestamp) |
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.
items deleted here are part of items that will be deleted in getEntriesWithNoVisitsOrOlderThanTimestamp?
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.
Hm, I think you have a point and the second part of getEntriesWithNoVisitsOrOlderThanTimestamp is redundant. The idea is to first delete the visits with a timestamp older than the parameter, and then delete the entries that have no remaining visits
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.
I've simplified all these logic, now it's only 2 delete clauses
} | ||
|
||
@Test | ||
fun whenDeleteOldItemsWithNoOldEnoughItemsThenTheyAreDeleted() { |
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.
name should be ...withOld..
instead of ...WithNoOld...
?
import com.duckduckgo.di.scopes.AppScope | ||
import com.duckduckgo.history.api.HistoryEntry | ||
import com.duckduckgo.history.api.NavigationHistory | ||
import com.squareup.anvil.annotations.ContributesBinding | ||
import io.reactivex.Single | ||
import javax.inject.Inject | ||
|
||
@ContributesBinding(AppScope::class) | ||
interface InternalNavigationHistory : NavigationHistory { |
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.
why we need this one here if you have HistoryRepository
that seems to be your internal Navigation Repository?
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.
RealNavigationHistory
is what contains the business logic, whereas NavigationRepository
is a bridge between RealNavigationHistory
(logic) and the data sources. This internal interface is added so we don't expose externally the ability to schedule data deletion. I don't think it would make sense for the repository to define the time interval for data deletion
67be27a
to
8a2b4ad
Compare
9cbb477
to
c0a8b79
Compare
8a2b4ad
to
e8d4f44
Compare
c0a8b79
to
8d3eaca
Compare
e8d4f44
to
6831b27
Compare
8d3eaca
to
a7e5ea0
Compare
Task/Issue URL: https://app.asana.com/0/0/1206969865711357/f
Description
See title
Steps to test this PR
Checkout this branch, go to HistoryDeletionWorker, and modify scheduleWorker adding setInitialDelay(5, TimeUnit.Minutes). Clear app data afterwards
Feature 1
HistoryDeletionWorker
, and modifyscheduleWorker
addingsetInitialDelay(5, TimeUnit.Minutes)
RealNavigationHistory
and modifyhistoryRepository.clearEntriesOlderThan(currentTimeProvider.localDateTimeNow().minusDays(30))
, changingminusDays(30)
tominusMinutes (2)
UI changes
N/A