parameters: (
      db: SessionManager, web3: Web3, redis: Redis, interval_seconds: int
  )
return_statement: return None
docstring: Checks if the trending job should re-run based off the last trending run's timestamp and
      the most recently indexed block's timestamp.
      If the most recently indexed block (rounded down to the nearest interval) is `interval_seconds`
      ahead of the last trending job run, then the job should re-run.
      The function returns the an int, representing the timestamp, if the jobs should re-run, else None
docstring_summary: Checks if the trending job should re-run based off the last trending run's timestamp and
      the most recently indexed block's timestamp.
      If the most recently indexed block (rounded down to the nearest interval) is `interval_seconds`
      ahead of the last trending job run, then the job should re-run.
      The function returns the an int, representing the timestamp, if the jobs should re-run, else None
docstring_tokens: Checks if the trending job should re - run based off the last trending run s timestamp and the most recently indexed block s timestamp . If the most recently indexed block ( rounded down to the nearest interval ) is interval_seconds ahead of the last trending job run then the job should re - run . The function returns the an int representing the timestamp if the jobs should re - run else None
function: def get_should_update_trending(
      db: SessionManager, web3: Web3, redis: Redis, interval_seconds: int
  ) -> Optional[int]:
      """
      Checks if the trending job should re-run based off the last trending run's timestamp and
      the most recently indexed block's timestamp.
      If the most recently indexed block (rounded down to the nearest interval) is `interval_seconds`
      ahead of the last trending job run, then the job should re-run.
      The function returns the an int, representing the timestamp, if the jobs should re-run, else None
      """
      with db.scoped_session() as session:
          current_db_block = (
              session.query(Block.blockhash).filter(Block.is_current == True).first()
          )
          current_block = web3.eth.getBlock(current_db_block[0], True)
          current_timestamp = current_block["timestamp"]
          block_datetime = floor_time(
              datetime.fromtimestamp(current_timestamp), interval_seconds
          )
  
          last_trending_datetime = get_last_trending_datetime(redis)
          if not last_trending_datetime:
              return int(block_datetime.timestamp())
  
          duration_since_last_index = block_datetime - last_trending_datetime
          if duration_since_last_index.total_seconds() >= interval_seconds:
              return int(block_datetime.timestamp())
  
      return None
function_tokens: def get_should_update_trending ( db : SessionManager , web3 : Web3 , redis : Redis , interval_seconds : int ) -> Optional [ int ] : with db . scoped_session ( ) as session : current_db_block = ( session . query ( Block . blockhash ) . filter ( Block . is_current == True ) . first ( ) ) current_block = web3 . eth . getBlock ( current_db_block [ 0 ] , True ) current_timestamp = current_block [ "timestamp" ] block_datetime = floor_time ( datetime . fromtimestamp ( current_timestamp ) , interval_seconds ) last_trending_datetime = get_last_trending_datetime ( redis ) if not last_trending_datetime : return int ( block_datetime . timestamp ( ) ) duration_since_last_index = block_datetime - last_trending_datetime if duration_since_last_index . total_seconds ( ) >= interval_seconds : return int ( block_datetime . timestamp ( ) ) return None