Fix update count, breakage from rebase, and broken tests.
The update count was broken because I added the join onto the apk table, and in the process, forced a GROUP BY on the AppProvider queries. This group by made the COUNT(*) actually count the number of apks for each app, not the total rows.
This commit is contained in:
parent
2a481f6889
commit
a2be7d9013
@ -61,7 +61,7 @@ import java.util.Locale;
|
||||
public final class Utils {
|
||||
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
private static final String TAG = "org.fdroid.fdroid.Utils";
|
||||
private static final String TAG = "fdroid.Utils";
|
||||
|
||||
public static final int BUFFER_SIZE = 4096;
|
||||
|
||||
@ -75,8 +75,6 @@ public final class Utils {
|
||||
public static final SimpleDateFormat LOG_DATE_FORMAT =
|
||||
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH);
|
||||
|
||||
private static final String TAG = "fdroid.Utils";
|
||||
|
||||
public static String getIconsDir(Context context) {
|
||||
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
|
||||
String iconsDir;
|
||||
|
@ -259,6 +259,7 @@ public class AppProvider extends FDroidProvider {
|
||||
private boolean isSuggestedApkTableAdded = false;
|
||||
private boolean requiresInstalledTable = false;
|
||||
private boolean categoryFieldAdded = false;
|
||||
private boolean countFieldAppended = false;
|
||||
|
||||
@Override
|
||||
protected String getRequiredTables() {
|
||||
@ -278,7 +279,8 @@ public class AppProvider extends FDroidProvider {
|
||||
|
||||
@Override
|
||||
protected String groupBy() {
|
||||
return DBHelper.TABLE_APP + ".id";
|
||||
// If the count field has been requested, then we want to group all rows together.
|
||||
return countFieldAppended ? null : DBHelper.TABLE_APP + ".id";
|
||||
}
|
||||
|
||||
public void addSelection(AppQuerySelection selection) {
|
||||
@ -329,7 +331,8 @@ public class AppProvider extends FDroidProvider {
|
||||
}
|
||||
|
||||
private void appendCountField() {
|
||||
appendField("COUNT(*) AS " + DataColumns._COUNT);
|
||||
countFieldAppended = true;
|
||||
appendField("COUNT( DISTINCT fdroid_app.id ) AS " + DataColumns._COUNT);
|
||||
}
|
||||
|
||||
private void addSuggestedApkVersionField() {
|
||||
|
@ -11,6 +11,9 @@ import mock.MockContextSwappableComponents;
|
||||
import mock.MockInstallablePackageManager;
|
||||
import org.fdroid.fdroid.data.ApkProvider;
|
||||
import org.fdroid.fdroid.data.AppProvider;
|
||||
import org.fdroid.fdroid.receiver.PackageAddedReceiver;
|
||||
import org.fdroid.fdroid.receiver.PackageRemovedReceiver;
|
||||
import org.fdroid.fdroid.receiver.PackageUpgradedReceiver;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
@ -19,7 +22,7 @@ import java.util.List;
|
||||
|
||||
public class TestUtils {
|
||||
|
||||
private static final String TAG = "org.fdroid.fdroid.TestUtils";
|
||||
private static final String TAG = "fdroid.TestUtils";
|
||||
|
||||
public static <T extends Comparable> void assertContainsOnly(List<T> actualList, T[] expectedArray) {
|
||||
List<T> expectedList = new ArrayList<T>(expectedArray.length);
|
||||
@ -134,7 +137,7 @@ public class TestUtils {
|
||||
|
||||
/**
|
||||
* Will tell {@code pm} that we are installing {@code appId}, and then alert the
|
||||
* {@link org.fdroid.fdroid.PackageAddedReceiver}. This will in turn update the
|
||||
* {@link org.fdroid.fdroid.receiver.PackageAddedReceiver}. This will in turn update the
|
||||
* "installed apps" table in the database.
|
||||
*/
|
||||
public static void installAndBroadcast(
|
||||
|
Loading…
x
Reference in New Issue
Block a user