code: def recent_activity(self, user_id):
          
          M = models  # noqa
  
          if request.args.get('limit'):
              limit = int(request.args.get('limit'))
          else:
              limit = 1000
  
          qry = (
              db.session.query(M.Log, M.Dashboard, M.Slice)
              .outerjoin(
                  M.Dashboard,
                  M.Dashboard.id == M.Log.dashboard_id,
              )
              .outerjoin(
                  M.Slice,
                  M.Slice.id == M.Log.slice_id,
              )
              .filter(
                  sqla.and_(
                      ~M.Log.action.in_(('queries', 'shortner', 'sql_json')),
                      M.Log.user_id == user_id,
                  ),
              )
              .order_by(M.Log.dttm.desc())
              .limit(limit)
          )
          payload = []
          for log in qry.all():
              item_url = None
              item_title = None
              if log.Dashboard:
                  item_url = log.Dashboard.url
                  item_title = log.Dashboard.dashboard_title
              elif log.Slice:
                  item_url = log.Slice.slice_url
                  item_title = log.Slice.slice_name
  
              payload.append({
                  'action': log.Log.action,
                  'item_url': item_url,
                  'item_title': item_title,
                  'time': log.Log.dttm,
              })
          return json_success(
              json.dumps(payload, default=utils.json_int_dttm_ser))
docs: Recent activity (actions) for a given user