parameters: (
      self,
      update_task: DatabaseTask,
      session: Session,
      playlist_factory_txs,
      block_number,
      block_timestamp,
      block_hash,
      _ipfs_metadata,  # prefix unused args with underscore to prevent pylint
      _blacklisted_cids,
  )
return_statement: return num_total_changes, playlist_ids
docstring: Return Tuple containing int representing number of Playlist model state changes found in transaction and set of processed playlist IDs.
docstring_summary: Return Tuple containing int representing number of Playlist model state changes found in transaction and set of processed playlist IDs.
docstring_tokens: Return Tuple containing int representing number of Playlist model state changes found in transaction and set of processed playlist IDs .
function: def playlist_state_update(
      self,
      update_task: DatabaseTask,
      session: Session,
      playlist_factory_txs,
      block_number,
      block_timestamp,
      block_hash,
      _ipfs_metadata,  # prefix unused args with underscore to prevent pylint
      _blacklisted_cids,
  ) -> Tuple[int, Set]:
      """Return Tuple containing int representing number of Playlist model state changes found in transaction and set of processed playlist IDs."""
      blockhash = update_task.web3.toHex(block_hash)
      num_total_changes = 0
      skipped_tx_count = 0
      # This stores the playlist_ids created or updated in the set of transactions
      playlist_ids: Set[int] = set()
  
      if not playlist_factory_txs:
          return num_total_changes, playlist_ids
  
      playlist_events_lookup: Dict[int, Dict[str, Any]] = {}
      for tx_receipt in playlist_factory_txs:
          txhash = update_task.web3.toHex(tx_receipt.transactionHash)
          for event_type in playlist_event_types_arr:
              playlist_events_tx = get_playlist_events_tx(
                  update_task, event_type, tx_receipt
              )
              processedEntries = 0  # if record does not get added, do not count towards num_total_changes
              for entry in playlist_events_tx:
                  existing_playlist_record = None
                  playlist_id = helpers.get_tx_arg(entry, "_playlistId")
                  try:
                      # look up or populate existing record
                      if playlist_id in playlist_events_lookup:
                          existing_playlist_record = playlist_events_lookup[playlist_id][
                              "playlist"
                          ]
                      else:
                          existing_playlist_record = lookup_playlist_record(
                              update_task, session, entry, block_number, txhash
                          )
  
                      # parse playlist event to add metadata to record
                      playlist_record = parse_playlist_event(
                          self,
                          update_task,
                          entry,
                          event_type,
                          existing_playlist_record,
                          block_timestamp,
                          session,
                      )
  
                      # process playlist record
                      if playlist_record is not None:
                          if playlist_id not in playlist_events_lookup:
                              playlist_events_lookup[playlist_id] = {
                                  "playlist": playlist_record,
                                  "events": [],
                              }
                          else:
                              playlist_events_lookup[playlist_id][
                                  "playlist"
                              ] = playlist_record
                          playlist_events_lookup[playlist_id]["events"].append(event_type)
                          playlist_ids.add(playlist_id)
                          processedEntries += 1
                  except EntityMissingRequiredFieldError as e:
                      logger.warning(f"Skipping tx {txhash} with error {e}")
                      skipped_tx_count += 1
                      add_node_level_skipped_transaction(
                          session, block_number, blockhash, txhash
                      )
                      pass
                  except Exception as e:
                      logger.info("Error in parse playlist transaction")
                      raise IndexingError(
                          "playlist", block_number, blockhash, txhash, str(e)
                      ) from e
              num_total_changes += processedEntries
  
      logger.info(
          f"index.py | playlists.py | There are {num_total_changes} events processed and {skipped_tx_count} skipped transactions."
      )
  
      for playlist_id, value_obj in playlist_events_lookup.items():
          logger.info(f"index.py | playlists.py | Adding {value_obj['playlist']})")
          if value_obj["events"]:
              invalidate_old_playlist(session, playlist_id)
              session.add(value_obj["playlist"])
  
      return num_total_changes, playlist_ids
function_tokens: def playlist_state_update ( self , update_task : DatabaseTask , session : Session , playlist_factory_txs , block_number , block_timestamp , block_hash , _ipfs_metadata , # prefix unused args with underscore to prevent pylint _blacklisted_cids , ) -> Tuple [ int , Set ] : blockhash = update_task . web3 . toHex ( block_hash ) num_total_changes = 0 skipped_tx_count = 0 # This stores the playlist_ids created or updated in the set of transactions playlist_ids : Set [ int ] = set ( ) if not playlist_factory_txs : return num_total_changes , playlist_ids playlist_events_lookup : Dict [ int , Dict [ str , Any ] ] = { } for tx_receipt in playlist_factory_txs : txhash = update_task . web3 . toHex ( tx_receipt . transactionHash ) for event_type in playlist_event_types_arr : playlist_events_tx = get_playlist_events_tx ( update_task , event_type , tx_receipt ) processedEntries = 0 # if record does not get added, do not count towards num_total_changes for entry in playlist_events_tx : existing_playlist_record = None playlist_id = helpers . get_tx_arg ( entry , "_playlistId" ) try : # look up or populate existing record if playlist_id in playlist_events_lookup : existing_playlist_record = playlist_events_lookup [ playlist_id ] [ "playlist" ] else : existing_playlist_record = lookup_playlist_record ( update_task , session , entry , block_number , txhash ) # parse playlist event to add metadata to record playlist_record = parse_playlist_event ( self , update_task , entry , event_type , existing_playlist_record , block_timestamp , session , ) # process playlist record if playlist_record is not None : if playlist_id not in playlist_events_lookup : playlist_events_lookup [ playlist_id ] = { "playlist" : playlist_record , "events" : [ ] , } else : playlist_events_lookup [ playlist_id ] [ "playlist" ] = playlist_record playlist_events_lookup [ playlist_id ] [ "events" ] . append ( event_type ) playlist_ids . add ( playlist_id ) processedEntries += 1 except EntityMissingRequiredFieldError as e : logger . warning ( f"Skipping tx {txhash} with error {e}" ) skipped_tx_count += 1 add_node_level_skipped_transaction ( session , block_number , blockhash , txhash ) pass except Exception as e : logger . info ( "Error in parse playlist transaction" ) raise IndexingError ( "playlist" , block_number , blockhash , txhash , str ( e ) ) from e num_total_changes += processedEntries logger . info ( f"index.py | playlists.py | There are {num_total_changes} events processed and {skipped_tx_count} skipped transactions." ) for playlist_id , value_obj in playlist_events_lookup . items ( ) : logger . info ( f"index.py | playlists.py | Adding {value_obj['playlist']})" ) if value_obj [ "events" ] : invalidate_old_playlist ( session , playlist_id ) session . add ( value_obj [ "playlist" ] ) return num_total_changes , playlist_ids