Commit 9adf9705 authored by Vincent Texier's avatar Vincent Texier

[enh] #798 add used_by property in sources table

parent eda2f50b
......@@ -10,4 +10,5 @@ class Source:
type = attr.ib(converter=str, validator=lambda i, a, s: s == "T" or s == "D")
amount = attr.ib(converter=int, hash=False)
base = attr.ib(converter=int, hash=False)
conditions = attr.ib(converter=str)
conditions = attr.ib(converter=str, hash=False)
used_by = attr.ib(converter=str, hash=False, default=None)
BEGIN TRANSACTION;
ALTER TABLE sources ADD COLUMN used_by VARCHAR(255) default null;
COMMIT;
......@@ -7,7 +7,7 @@ from .connections import ConnectionsRepo
from .identities import IdentitiesRepo
from .blockchains import BlockchainsRepo
from .certifications import CertificationsRepo
from .transactions import TransactionsRepo, Transaction
from .transactions import TransactionsRepo
from .dividends import DividendsRepo
from .nodes import NodesRepo, Node
from .sources import SourcesRepo
......@@ -90,6 +90,7 @@ class SakiaDatabase:
self.drop_incorrect_nodes,
self.insert_last_mass_attribute,
self.add_sources_conditions_property,
self.add_sources_used_by_property,
]
def upgrade_database(self, to=0):
......@@ -223,6 +224,17 @@ class SakiaDatabase:
with self.conn:
self.conn.executescript(sql_file.read())
def add_sources_used_by_property(self):
self._logger.debug("Add sources used_by property")
sql_file = open(
os.path.join(
os.path.dirname(__file__), "007_add_sources_used_by_property.sql"
),
"r",
)
with self.conn:
self.conn.executescript(sql_file.read())
def version(self):
with self.conn:
c = self.conn.execute("SELECT * FROM meta WHERE id=1")
......
......@@ -267,6 +267,7 @@ class SourcesServices(QObject):
amount=source["amount"],
base=source["base"],
conditions=source["conditions"],
used_by=None,
)
self._sources_processor.insert(entity)
except AttributeError as e:
......
......@@ -14,6 +14,7 @@ def test_add_get_drop_source(meta_repo):
1565,
1,
"SIG(FADxcH5LmXGmGFgdixSes6nWnC4Vb4pRUBYT81zQRhjn)",
None,
)
)
source = sources_repo.get_one(
......@@ -45,6 +46,7 @@ def test_add_get_multiple_source(meta_repo):
1565,
1,
"SIG(FADxcH5LmXGmGFgdixSes6nWnC4Vb4pRUBYT81zQRhjn)",
None,
)
)
sources_repo.insert(
......@@ -57,6 +59,7 @@ def test_add_get_multiple_source(meta_repo):
726946,
1,
"SIG(FADxcH5LmXGmGFgdixSes6nWnC4Vb4pRUBYT81zQRhjn)",
None,
)
)
sources = sources_repo.get_all(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment