def METHOD_NAME(app):
    with app.app_context():
        db_mock = get_db()
    with db_mock.scoped_session() as session:
        session.bulk_save_objects(
            [
                AggregateDailyAppNameMetric(
                    application_name="best-app", count=4, timestamp=yesterday
                ),
                AggregateDailyAppNameMetric(
                    application_name="best-app", count=3, timestamp=day_before_yesterday
                ),
                AggregateDailyAppNameMetric(
                    application_name="top-app", count=6, timestamp=day_before_yesterday
                ),
                AggregateMonthlyAppNameMetric(
                    application_name="other-app",
                    count=3,
                    timestamp=today - timedelta(days=100),
                ),
                AggregateMonthlyAppNameMetric(
                    application_name="top-app",
                    count=6,
                    timestamp=today - timedelta(days=100),
                ),
            ]
        )
        # Min count of 4
        aggregate_metrics = _get_historical_app_metrics(session, 4)
        daily_aggregate_metrics = aggregate_metrics["daily"]
        monthly_aggregate_metrics = aggregate_metrics["monthly"]
        assert len(daily_aggregate_metrics.items()) == 2
        assert daily_aggregate_metrics[str(yesterday)]["best-app"] == 4
        assert daily_aggregate_metrics[str(day_before_yesterday)]["top-app"] == 6
        assert len(monthly_aggregate_metrics.items()) == 1
        assert (
            monthly_aggregate_metrics[str(today - timedelta(days=100))]["top-app"] == 6
        )