Update harvest.py to include flag for outdated contracts
tpmccallum opened this issue · 5 comments
Tasks:
-
- Ensure
harvestFull
andharvestTopup
will set a new index attribute called "complete" to True or False, based on the existing smart contract's "status" value.
- Ensure
-
- Ensure that the
harvestStateUpdate
functionality only fetches records where "complete" is set to False.
- Ensure that the
-
- Ensure that the
harvestStateUpdate
will update the index attribute called "comeplete" to True or False, based on the current/existing smart contract's "status" value.
- Ensure that the
If the status of a contract reflects that the product giveaway has been drawn and that no other activity will ever take place, we need some data to reflect this. Otherwise the software which updates the indices will continue to recheck contract[s] which are not ever going to update. This will improve efficiency and speed.
Suggest an attribute such as complete=True/complete=False
The harvestFull
and harvestTopup
will set complete to True or False during the first time the smart contract instance is indexed (it will always be set) depending on the contract instances "status" variable.
status of 0 -> complete = False
status of 1 -> complete = True
The harvestStateUpdate
will only fetch records from the index which have complete set to False. During the update the harvestStateUpdate
will adjust the value of "complete" accordingly (again based on the status)
Initial harvest logic
if theStatus == 0:
outerData['requiresUpdating'] = "yes"
elif theStatus == 1:
outerData['requiresUpdating'] = "no"
ii
Created the following query
{'query': {'bool': {'must': [{'match': {'requiresUpdating': 'yes'}}], 'should': [{'wildcard': {'contractAddress': '0x*'}}]}}, '_source': ['contractAddress']}
via the following Python
>>> dQuery = {}
>>> dWildCard = {}
>>> dContractAddress = {}
>>> lContractAddress = []
>>> dContractAddress["contractAddress"] = "0x*"
>>> dWildCard["wildcard"] = dContractAddress
>>> dMatch = {}
>>> dReauiresUpdating = {}
>>> dReauiresUpdating["requiresUpdating"] = "yes"
>>> dMatch["match"] = dReauiresUpdating
>>> lMust = []
>>> lMust.append(dMatch)
>>> dBool = {}
>>> dBool["must"] = lMust
>>> lShould = []
>>> lShould.append(dWildCard)
>>> dBool["should"] = lShould
>>> dOb = {}
>>> dOb["bool"] = dBool
>>> dQuery["query"] = dOb
>>> lContractAddress.append("contractAddress")
>>> dQuery["_source"] = lContractAddress
>>> print(dQuery)
This takes care of Tasks i and ii (as noted in the initialization of this issue). Working on iii next.
The function which repeatedly updates a contract instance state can now update whether or not the contract should be rechecked in the future.
theStatus = freshFunctionData['status']
if theStatus == 0:
outerData['requiresUpdating'] = "yes"
elif theStatus == 1:
outerData['requiresUpdating'] = "no"
This takes care of item iii