code: def get_last_calc_id(username=None):
      
      if config.dbserver.multi_user:
          job = dbcmd('get_job', -1, username)  # can be None
          return getattr(job, 'id', 0)
      else:  # single user
          return datastore.get_last_calc_id()
docs: :param username: if given, restrict to it
      :returns: the last calculation in the database or the datastore