also insert types in ksx script
This commit is contained in:
parent
6da1a295cf
commit
4352284983
2 changed files with 13 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
|||
import hashlib
|
||||
import logging
|
||||
from dataclasses import dataclass
|
||||
from operator import add
|
||||
|
||||
import click
|
||||
import colorama
|
||||
|
@ -109,13 +110,20 @@ def main(db_name, db_user, db_password, db_host, db_port):
|
|||
f"Out of {len(trackfiles)} trackfiles, and out of {len(hashed_files)} files in UpEnd, {len(tf_and_ue)} are present in both."
|
||||
)
|
||||
|
||||
# logger.info("Inserting types...")
|
||||
logger.info("Inserting types...")
|
||||
ksx_type_result = upend.insert((None, "TYPE", "KSX_TRACK_MOODS"))
|
||||
ksx_type_addr = list(ksx_type_result.values())[0]["entity"]
|
||||
upend.insert((ksx_type_addr, "TYPE_REQUIRES", "KSX_ENERGY"))
|
||||
upend.insert((ksx_type_addr, "TYPE_REQUIRES", "KSX_SERIOUSNESS"))
|
||||
upend.insert((ksx_type_addr, "TYPE_REQUIRES", "KSX_TINT"))
|
||||
upend.insert((ksx_type_addr, "TYPE_REQUIRES", "KSX_MATERIALS"))
|
||||
|
||||
logger.info("Inserting mood data...")
|
||||
for sum in tqdm(tf_and_ue):
|
||||
tf = sha256_trackfiles[sum]
|
||||
address = sha256_entities[sum]
|
||||
|
||||
upend.insert((address, "IS", ksx_type_addr), value_type="Address")
|
||||
upend.insert((address, "KSX_ENERGY", tf.energy))
|
||||
upend.insert((address, "KSX_SERIOUSNESS", tf.seriousness))
|
||||
upend.insert((address, "KSX_TINT", tf.tint))
|
||||
|
|
|
@ -88,7 +88,9 @@ class UpEnd:
|
|||
for chunk in request.iter_content(chunk_size=chunk_size):
|
||||
yield chunk
|
||||
|
||||
def insert(self, entry: Union[UpEndTriplet, UpEndEntry]) -> Dict[str, Any]:
|
||||
def insert(
|
||||
self, entry: Union[UpEndTriplet, UpEndEntry], value_type: str = "Value"
|
||||
) -> Dict[str, Any]:
|
||||
entry_out = None
|
||||
if type(entry) is tuple:
|
||||
entry_out = UpEndEntry(*entry)
|
||||
|
@ -102,7 +104,7 @@ class UpEnd:
|
|||
json={
|
||||
"entity": entry_out.entity,
|
||||
"attribute": entry_out.attribute,
|
||||
"value": {"t": "Value", "c": entry_out.value},
|
||||
"value": {"t": value_type, "c": entry_out.value},
|
||||
},
|
||||
)
|
||||
request.raise_for_status()
|
||||
|
|
Loading…
Reference in a new issue