# 03 Spotify Convert to Nodes_and_Rels.r

# This is an alternative to  '03 Spotify Convert to Nodes_and_Rels.r'
# I believe the original one was before I manually calculated the counts

  ## There is no real need for a deep copy, unless dev'ing

  if (SAVE.BACKUP)
    jesusForData(DB.using, ArtistNodes, ArtistArtist, verbose=TRUE)

  if (FALSE)  {
    NODES.DT <- copy(ArtistNodes)
    RELS.DT  <- copy(ArtistArtist)
  } else {
    NODES.DT <- ArtistNodes
    RELS.DT  <- ArtistArtist
  }

  # Node should have a default 'name'
  setnames(NODES.DT, "artistname", "name")

  # The name of the nodes should not be in the RELS.DT 
  # If they made it along, it was probably for debugging purposes. 
  # Make sure to clear them before exporting
  if (any(c("Art1", "Art2") %in% names(RELS.DT)))
    suppressWarnings(RELS.DT[, c("Art1", "Art2") := NULL]) # no warn, in case only one of exists


  if (SAVE.BACKUP) {
    jesusForData(NODES.DT, RELS.DT)
    saveImageTo()
  }
