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

Refactoring StorageHelper class #851

Merged
merged 16 commits into from
Oct 29, 2018

Conversation

jaeklim
Copy link
Contributor

@jaeklim jaeklim commented Oct 26, 2018

  • Has CHANGELOG.md been updated?
  • Are tests passing locally?
  • Are the files formatted correctly?
  • Did you add unit tests?
  • Did you test your change with either the sample apps that are included in the repository or with a blank app that uses your change?

@coveralls
Copy link

coveralls commented Oct 26, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling 1236ea8 on feature/refactor-storage-helper into 81aed43 on develop.

@MatkovIvan MatkovIvan changed the title [WIP] Refactoring StorageHelper class Refactoring StorageHelper class Oct 29, 2018
mSQLiteOpenHelper = helper;
String[] getColumnNames() {

// TODO: Below line doesn't look efficient to get column names. Could use "PRAGMA table_info(table-name)" to avoid getting all data back from database just to get column names.
Copy link
Member

Choose a reason for hiding this comment

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

How about let's do this TODO now? 😄

Copy link
Member

Choose a reason for hiding this comment

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

This is used only in unit tests we could just remove the comment

persistence.close();
}

/* There is a error log. */
Copy link
Member

Choose a reason for hiding this comment

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

a => an

Copy link
Member

Choose a reason for hiding this comment

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

Please fix all occurrence in this file

Constants.loadFromContext(sContext);
}

private static int getCursorSize(Cursor cursor) {
Copy link
Member

Choose a reason for hiding this comment

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

Can use cursor.getCount() now that we removed a layer.

long databaseId = mDatabaseStorage.put(contentValues);
long databaseId = mDatabaseManager.put(contentValues);
if (databaseId == -1) {
AppCenterLog.warn(LOG_TAG, "Failed to store a log to the Persistence database for log type " + log.getType() + ".");
Copy link
Member

Choose a reason for hiding this comment

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

Need to throw PersistenceException

try {
Cursor cursor = mDatabaseManager.getCursor(builder, new String[]{group}, true);
count = cursor.getCount();
cursor.close();
Copy link
Member

Choose a reason for hiding this comment

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

try finally

String[] selectionArgs = new String[]{value.toString()};
Cursor cursor = getCursor(builder, selectionArgs, false);
ContentValues values = cursor.moveToFirst() ? buildValues(cursor) : null;
cursor.close();
Copy link
Member

Choose a reason for hiding this comment

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

finally

mSQLiteOpenHelper = helper;
String[] getColumnNames() {

// TODO: Below line doesn't look efficient to get column names. Could use "PRAGMA table_info(table-name)" to avoid getting all data back from database just to get column names.
Copy link
Member

Choose a reason for hiding this comment

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

This is used only in unit tests we could just remove the comment


/* groupCount should be <= 9. */
final int groupCount = 4;
final int groupCount = 1;
Copy link
Member

Choose a reason for hiding this comment

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

what is this change?

@guperrot guperrot changed the base branch from develop to feature/priority October 29, 2018 23:51
@guperrot guperrot merged commit a35d53f into feature/priority Oct 29, 2018
@guperrot guperrot deleted the feature/refactor-storage-helper branch October 29, 2018 23:55
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

Successfully merging this pull request may close these issues.

5 participants