get all dashboards for a given user.
171706
public function getAll(User $user)
    {
        return array_map(function ($dashboard) {
            return $this->exportDashboard($dashboard);
        }, $this->getRepository()->findBy(['creator' => $user]));
    }
1107640
public List<Post> userDashboard(Map<String, ?> options) {
        return requestBuilder.get("/user/dashboard", options).getPosts();
    }
93171
def export_dashboards(print_stdout, dashboard_file):
    """"""
    data = dashboard_import_export.export_dashboards(db.session)
    if print_stdout or not dashboard_file:
        print(data)
    if dashboard_file:
        logging.info('Exporting dashboards to %s', dashboard_file)
        with open(dashboard_file, 'w') as data_stream:
            data_stream.write(data)
612927
public function getList(array $options)
    {
        $options += array('active' => true);

        $sql = 'SELECT * FROM dashboard';

        $conditions = array();

        if (isset($options['user_id'])) {
            $sql .= ' WHERE user_id=?';
            $conditions[] = $options['user_id'];
        }

        $list = $this->db->fetch($sql, $conditions, array('unserialize' => 'data'));
        $result = $this->prepareList($list, $options);

        $this->hook->attach('dashboard.get.user', $result, $this);
        return $result;
    }
702534
public function actionIndex()
	{
		// Fetch all the dashboard cards for the current user
		$cards 		= $this->loadDashboardCards();
		$cardData 	= array();

		// Find all the metadata for those cards and load them
		foreach ($cards->value as $id=>$url)
		{
			$metadata 		= $this->loadCardDetailsModel($id);
			$cardData[$id] 	= $metadata->value;
		}

		return array(
           'cards'    => $cards->value,
           'cardData' => $cardData
       );
	}
1281347
def dashboard(request):
    ""
    end_time = now()
    start_time = end_time - timedelta(days=7)
    defaults = {'start': start_time, 'end': end_time}

    form = DashboardForm(data=request.GET or defaults)
    if form.is_valid():
        start_time = form.cleaned_data['start']
        end_time = form.cleaned_data['end']

    # determine when tracking began
    try:
        obj = Visitor.objects.order_by('start_time')[0]
        track_start_time = obj.start_time
    except (IndexError, Visitor.DoesNotExist):
        track_start_time = now()

    # If the start_date is before tracking began, warn about incomplete data
    warn_incomplete = (start_time < track_start_time)

    # queries take `date` objects (for now)
    user_stats = Visitor.objects.user_stats(start_time, end_time)
    visitor_stats = Visitor.objects.stats(start_time, end_time)
    if TRACK_PAGEVIEWS:
        pageview_stats = Pageview.objects.stats(start_time, end_time)
    else:
        pageview_stats = None

    context = {
        'form': form,
        'track_start_time': track_start_time,
        'warn_incomplete': warn_incomplete,
        'user_stats': user_stats,
        'visitor_stats': visitor_stats,
        'pageview_stats': pageview_stats,
    }
    return render(request, 'tracking/dashboard.html', context)
1151708
def all(self, res):
        ""
        B = get_backend()
        return B.get_objects(B.get_concrete(res))
769303
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))
463957
def import_dashboards(session, data_stream, import_time=None):
    """"""
    current_tt = int(time.time())
    import_time = current_tt if import_time is None else import_time
    data = json.loads(data_stream.read(), object_hook=decode_dashboards)
    # TODO: import DRUID datasources
    for table in data['datasources']:
        type(table).import_obj(table, import_time=import_time)
    session.commit()
    for dashboard in data['dashboards']:
        Dashboard.import_obj(
            dashboard, import_time=import_time)
    session.commit()
522377
def horizon_main_nav(context):
    """"""
    if 'request' not in context:
        return {}
    current_dashboard = context['request'].horizon.get('dashboard', None)
    dashboards = []
    for dash in Horizon.get_dashboards():
        if dash.can_access(context):
            if callable(dash.nav) and dash.nav(context):
                dashboards.append(dash)
            elif dash.nav:
                dashboards.append(dash)
    return {'components': dashboards,
            'user': context['request'].user,
            'current': current_dashboard,
            'request': context['request']}
292882
def horizon_dashboard_nav(context):
    """"""
    if 'request' not in context:
        return {}
    dashboard = context['request'].horizon['dashboard']
    panel_groups = dashboard.get_panel_groups()
    non_empty_groups = []

    for group in panel_groups.values():
        allowed_panels = []
        for panel in group:
            if (callable(panel.nav) and panel.nav(context) and
                    panel.can_access(context)):
                allowed_panels.append(panel)
            elif (not callable(panel.nav) and panel.nav and
                    panel.can_access(context)):
                allowed_panels.append(panel)
        if allowed_panels:
            if group.name is None:
                non_empty_groups.append((dashboard.name, allowed_panels))
            else:
                non_empty_groups.append((group.name, allowed_panels))

    return {'components': OrderedDict(non_empty_groups),
            'user': context['request'].user,
            'current': context['request'].horizon['panel'].slug,
            'request': context['request']}
1316792
private function loadDashboardCards()
	{
		// Fetch all the dashboard cards for the current user
		$model = UserMetadata::model()->getPrototype('UserMetadata', array(
		             'user_id' => $this->user->id,
		             'key' => 'dashboard_cards'
		         ), array('value' => '{}'));

		$model->value = CJSON::decode($model->value);

		return $model;
	}
513513
def get_notifications(user):
    ''''''
    notifications = []

    for name, func in _providers.items():
        notifications.extend([{
            'type': name,
            'created_on': dt,
            'details': details
        } for dt, details in func(user)])

    return notifications
570476
def _ensure_panel_ids(dashboard):
    ''''''
    panel_id = 1
    for row in dashboard.get('rows', []):
        for panel in row.get('panels', []):
            panel['id'] = panel_id
            panel_id += 1
150009
def get_app_index_dashboard(context):
    
    # this is a mess, needs cleanup !
    app = context['app_list'][0]
    model_list = []
    app_label = None
    app_title = app['name']
    admin_site = get_admin_site(context=context)

    for model, model_admin in admin_site._registry.items():
        if app['app_label'] == model._meta.app_label:
            split = model.__module__.find(model._meta.app_label)
            app_label = model.__module__[0:split] + model._meta.app_label
            for m in app['models']:
                if m['name'] == capfirst(model._meta.verbose_name_plural):
                    mod = '%s.%s' % (model.__module__, model.__name__)
                    model_list.append(mod)

    # if an app has registered its own dashboard, use it
    if app_label is not None and app_label in Registry.registry:
        return Registry.registry[app_label](app_title, model_list)

    # try to discover a general app_index dashboard (with fallback to the
    # default dashboard)
    return _get_dashboard_cls(getattr(
        settings,
        'ADMIN_TOOLS_APP_INDEX_DASHBOARD',
        'admin_tools.dashboard.dashboards.DefaultAppIndexDashboard'
    ), context)(app_title, model_list)
610919
public static @Nonnull
    Collection<User> getAll() {
        final IdStrategy strategy = idStrategy();
        ArrayList<User> users = new ArrayList<>(AllUsers.values());
        users.sort((o1, o2) -> strategy.compare(o1.getId(), o2.getId()));
        return users;
    }
607958
def get_queryset(self, request):
        """"""
        qs = super(TenantGroupAdmin, self).get_queryset(request)
        if not request.user.is_superuser:
            qs = qs.filter(tenantrole__user=request.user,
                           tenantrole__role=TenantRole.ROLE_GROUP_MANAGER)
        return qs