mvarnagiris / financius

Personal expense manager
GNU General Public License v2.0
626 stars 254 forks source link

Majority of tags have disappeared after update #386

Open passy opened 9 years ago

passy commented 9 years ago

I'm connected with sync and have just noticed that a good chunk of my tags, both custom ones and the ones from the original set have disappeared. The transactions they were associated with, however, are still there.

I have backups from before they went missing but obviously can't apply those now. Do you have any idea what could have happened if there's a chance for me to restore them?

passy commented 9 years ago

Here's a diff of the tags backups before and after. Please note that the additions at the bottom are my attempt to restore the old behavior, but I stopped doing that after a while.

https://gist.github.com/passy/d813262f1d107c316a9a

It seems that only entries with strings (as in: not uuids) as ids were affected. Is this something the sync now requires? I guess my best hope of restoring these would be to search/replace the tags with uuids in that case.

passy commented 9 years ago

While I don't have a good way to prove my hypothesis, I hacked a small script together to replace the non-uuid identifiers for tags:

#!/usr/bin/env python3

import json
import sys
import uuid

with open(sys.argv[1], 'r') as fp:
    f = json.load(fp)

    # Get all old tags that need to be upgraded
    tags = list(filter(lambda x: x['id'].startswith('c_'), f['tags']))
    tx = f['transactions']

    for tag in tags:
        new_id = str(uuid.uuid4())

        for t in tx:
            t['tag_ids'] = list(map(lambda x: new_id if x == tag['id'] else x,
                                    t['tag_ids']))

        tag['id'] = new_id

    f.update(tags=tags, transactions=tx)

    print(json.dumps(f, indent=4))

I can import this fine, but as soon as I go online, the sync data mows down everything I have locally; thus replacing my "fixed" tags. Is there a way to reset/wipe the cloud data, @mvarnagiris?

MaicolBen commented 9 years ago

I log in a new phone and only the original tags dissappear, it is a pity because the transactions lost a lot of information

dANNYdANNO commented 8 years ago

I had the same problem like MaicolBen, is there a solution to this problem?