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

Move AppDaysUsedRepository to browser-api so it can be accessed from autofill #4474

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@ import kotlinx.coroutines.withContext

private val formatter = SimpleDateFormat("yyyy-MM-dd", Locale.US)

interface AppDaysUsedRepository {
suspend fun getNumberOfDaysAppUsed(): Long
suspend fun recordAppUsedToday()
suspend fun getNumberOfDaysAppUsedSinceDate(date: Date): Long
suspend fun getLastActiveDay(): String
suspend fun getPreviousActiveDay(): String?
}

class AppDaysUsedDatabaseRepository(private val appDaysUsedDao: AppDaysUsedDao) : AppDaysUsedRepository {

private val singleThreadedDispatcher = Executors.newSingleThreadExecutor().asCoroutineDispatcher()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2024 DuckDuckGo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.duckduckgo.app.usage.app

import java.util.*

/**
* Repository for storing and retrieving the number of days the app has been used
*/
interface AppDaysUsedRepository {
Copy link
Contributor

Choose a reason for hiding this comment

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

QQ: Are we planning to revert this once survey completed?

sgtm now to unblock and release the autofill survey. However, if final, we should discuss the api change to validate what makes sense to expose, how, where, etc.

Copy link
Member Author

Choose a reason for hiding this comment

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

Wasn't planning to revert, as the changes seem generally useful.

we should discuss the api change

that was why it was added to the API proposal a few weeks back.

sgtm now to unblock and release the autofill survey

Ok, I will carry on with this as planned and can discuss if there should be additional changes to the API made afterwards.


/**
* Get the number of days the app has been used
*/
suspend fun getNumberOfDaysAppUsed(): Long

/**
* Record that the app has been used today
*/
suspend fun recordAppUsedToday()

/**
* Get the number of days the app has been used since a given date
*/
suspend fun getNumberOfDaysAppUsedSinceDate(date: Date): Long

/**
* Get the last day the app was used
*/
suspend fun getLastActiveDay(): String

/**
* Get the previous active day
*/
suspend fun getPreviousActiveDay(): String?
}