Skip to content

Commit

Permalink
Add some verbosity to scrubbing
Browse files Browse the repository at this point in the history
This gives the user a primitive way to track progress for long
running Check & Repair actions by adding
--log gnc.engine.scrub=info to the command line options
  • Loading branch information
gjanssens committed Feb 22, 2015
1 parent 208cf51 commit de8d4c8
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 12 deletions.
14 changes: 12 additions & 2 deletions src/engine/Scrub.c
Expand Up @@ -283,23 +283,33 @@ xaccAccountTreeScrubImbalance (Account *acc)
void
xaccAccountScrubImbalance (Account *acc)
{
GList *node;
GList *node, *splits;
const char *str;
gint split_count = 0, curr_split_no = 1;

if (!acc) return;

str = xaccAccountGetName(acc);
str = str ? str : "(null)";
PINFO ("Looking for imbalance in account %s \n", str);

for (node = xaccAccountGetSplitList(acc); node; node = node->next)
splits = xaccAccountGetSplitList(acc);
split_count = g_list_length (splits);
for (node = splits; node; node = node->next)
{
Split *split = node->data;
Transaction *trans = xaccSplitGetParent(split);

PINFO("Start processing split %d of %d",
curr_split_no, split_count);

xaccTransScrubCurrency(trans);

xaccTransScrubImbalance (trans, gnc_account_get_root (acc), NULL);

PINFO("Finished processing split %d of %d",
curr_split_no, split_count);
curr_split_no++;
}
}

Expand Down
26 changes: 23 additions & 3 deletions src/engine/ScrubBusiness.c
Expand Up @@ -41,7 +41,10 @@
#include "ScrubBusiness.h"
#include "Transaction.h"

static QofLogModule log_module = GNC_MOD_LOT;
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "gnc.engine.scrub"

static QofLogModule log_module = G_LOG_DOMAIN;

// A helper function that takes two splits. If the splits are of opposite sign
// it reduces the biggest split to have the same value (but with opposite sign)
Expand Down Expand Up @@ -465,22 +468,39 @@ void
gncScrubBusinessAccountLots (Account *acc)
{
LotList *lots, *node;
gint lot_count = 0;
gint curr_lot_no = 1;
const gchar *str;

if (!acc) return;
if (FALSE == xaccAccountIsAPARType (xaccAccountGetType (acc))) return;

ENTER ("(acc=%s)", xaccAccountGetName(acc));
str = xaccAccountGetName(acc);
str = str ? str : "(null)";

ENTER ("(acc=%s)", str);
PINFO ("Cleaning up superfluous lot links in account %s \n", str);
xaccAccountBeginEdit(acc);

lots = xaccAccountGetLotList(acc);
lot_count = g_list_length (lots);
for (node = lots; node; node = node->next)
{
GNCLot *lot = node->data;

PINFO("Start processing lot %d of %d",
curr_lot_no, lot_count);

if (lot)
gncScrubBusinessLot (lot);

PINFO("Finished processing lot %d of %d",
curr_lot_no, lot_count);
curr_lot_no++;
}
g_list_free(lots);
xaccAccountCommitEdit(acc);
LEAVE ("(acc=%s)", xaccAccountGetName(acc));
LEAVE ("(acc=%s)", str);
}

/* ============================================================== */
Expand Down
23 changes: 16 additions & 7 deletions src/gnome/gnc-plugin-page-register.c
Expand Up @@ -3736,10 +3736,8 @@ gnc_plugin_page_register_cmd_scrub_all (GtkAction *action,
GncPluginPageRegisterPrivate *priv;
Query *query;
Account *root;
Transaction *trans;
GNCLot *lot;
Split *split;
GList *node;
GList *node, *splits;
gint split_count = 0, curr_split_no = 1;

g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER(plugin_page));

Expand All @@ -3756,17 +3754,28 @@ gnc_plugin_page_register_cmd_scrub_all (GtkAction *action,
gnc_suspend_gui_refresh();
root = gnc_get_current_root_account();

for (node = qof_query_run(query); node; node = node->next)
splits = qof_query_run(query);
split_count = g_list_length (splits);
for (node = splits; node; node = node->next)
{
split = node->data;
trans = xaccSplitGetParent(split);
GNCLot *lot;
Split *split = node->data;
Transaction *trans = xaccSplitGetParent(split);


PINFO("Start processing split %d of %d",
curr_split_no, split_count);

xaccTransScrubOrphans(trans);
xaccTransScrubImbalance(trans, root, NULL);

lot = xaccSplitGetLot (split);
if (lot && xaccAccountIsAPARType (xaccAccountGetType (xaccSplitGetAccount (split))))
gncScrubBusinessLot (lot);

PINFO("Finished processing split %d of %d",
curr_split_no, split_count);
curr_split_no++;
}

gnc_resume_gui_refresh();
Expand Down

0 comments on commit de8d4c8

Please sign in to comment.