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

Remake lastScheduledSync to save the 10 latest sync times instead the most recent one #1383

Open
hsjoberg opened this issue Nov 27, 2023 · 0 comments
Labels
android backend Issues regarding the Java backend android This issue relates to the Android build good first issue Good for newcomers
Milestone

Comments

@hsjoberg
Copy link
Owner

Currently writeLastScheduledSyncToDb() and writeLastScheduledSyncAttemptToDb() in LndMobileScheduledSyncWorker.java saves the most recent time.

private void writeLastScheduledSyncAttemptToDb() {
SQLiteDatabase db = dbSupplier.get();
String key = "lastScheduledSyncAttempt";
Long tsLong = System.currentTimeMillis() / 1000;
String value = tsLong.toString();
String sql = "INSERT OR REPLACE INTO catalystLocalStorage VALUES (?, ?);";
SQLiteStatement statement = db.compileStatement(sql);
try {
db.beginTransaction();
statement.clearBindings();
statement.bindString(1, key);
statement.bindString(2, value);
statement.execute();
db.setTransactionSuccessful();
} catch (Exception e) {
HyperLog.w(TAG, e.getMessage(), e);
} finally {
try {
db.endTransaction();
} catch (Exception e) {
HyperLog.w(TAG, e.getMessage(), e);
}
}
}
private void writeLastScheduledSyncToDb() {
SQLiteDatabase db = dbSupplier.get();
String key = "lastScheduledSync";
Long tsLong = System.currentTimeMillis() / 1000;
String value = tsLong.toString();
String sql = "INSERT OR REPLACE INTO catalystLocalStorage VALUES (?, ?);";
SQLiteStatement statement = db.compileStatement(sql);
try {
db.beginTransaction();
statement.clearBindings();
statement.bindString(1, key);
statement.bindString(2, value);
statement.execute();
db.setTransactionSuccessful();
} catch (Exception e) {
HyperLog.w(TAG, e.getMessage(), e);
} finally {
try {
db.endTransaction();
} catch (Exception e) {
HyperLog.w(TAG, e.getMessage(), e);
}
}
}

Instead make this to a JSON array containing timestamps of the 10 most recent sync times.

@hsjoberg hsjoberg added android backend Issues regarding the Java backend android This issue relates to the Android build good first issue Good for newcomers labels Nov 27, 2023
@hsjoberg hsjoberg added this to the 0.7.0 milestone Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android backend Issues regarding the Java backend android This issue relates to the Android build good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant