定制 igorsgm/laravel-redash 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

igorsgm/laravel-redash

最新稳定版本:1.2.0

Composer 安装命令:

composer require igorsgm/laravel-redash

包简介

📊 • A Laravel wrapper to empower your applications with Redash.io APIs. Extract, analyze, and leverage your Redash data right from your app!

README 文档

README

Unleash the power of Redash.io APIs in your Laravel applications. This package allows you to easily extract, analyze, and leverage your data directly within your application. Transform your data management today!

Latest Version on Packagist GitHub Tests Action Status Test Coverage Code Quality Total Downloads

✨ Features

  • Queries: Easily create, edit, or archive query objects directly from your Laravel application. The package returns paginated arrays of query objects and supports the extraction of individual query objects too.
  • Query Results: Initiate a new query execution or return a cached result effortlessly. Handle parameterized queries and manage max_age for cache bypassing with provided methods.
  • Dashboards: Create, edit, or archive dashboard objects seamlessly. Fetch an array of dashboard objects or individual ones directly from your Laravel application.
  • Jobs: Monitor the status of your query tasks effectively.

1️⃣ Installation

  • You can install the package via composer:
composer require igorsgm/laravel-redash
  • You can publish the config file with:
php artisan vendor:publish --tag="laravel-redash-config"

2️⃣ Usage

Define Redash API credentials in your .env file. i.e.:

REDASH_BASE_URL=foo:bar
REDASH_API_KEY=12345678900987654321

Summary

Resource Methods
Redash::queries() all, get, create, update, delete, getCachedResult, executeOrGetResult, getResult
Redash::queryResults() get
Redash::dashboards() all, get, create, update, delete
Redash::jobs() get

Queries

// Returns a paginated array of query objects.
Redash::queries()->all();

// Returns an individual query object.
Redash::queries()->get($queryId);

// Create a new query object.
Redash::queries()->create([
    'name' => 'My Query',
    'data_source_id' => 1,
    'query' => 'SELECT * FROM table',
    'description' => 'My Query Description',
    // ...
]);

// Edit an existing query object.
Redash::queries()->update($queryId, [
    'name' => 'My New Query Name',
    // ...
]);

// Archive an existing query.
Redash::queries()->delete($queryId);

// Get a cached result for this query ID
Redash::queries()->getCachedResult($queryId);

// Initiates a new query execution or returns a cached result.
Redash::queries()->executeOrGetResult($queryId, [
    'parameters' => [
        'foo' => 'bar',
    ],
    'max_age' => 0,
]);
  • Execute a Query and return its result once ready (custom method).
// The maximum age (in milliseconds) of a cached result that the method should return.
// If a cached result is older than this, a new query execution will begin.
// Set to `0` to always start a new execution.
$maxAge = 1800;

// The number of times to retry the query execution if it is still in progress.
$retryAttempts = 20;

Redash::queries()->getResult($queryId, [
    'foo' => 'bar',
], $maxAge, $retryAttempts);

Query Results

// Returns a query result
Redash::queryResults()->get($queryResultId);

Dashboards

Redash::dashboards()->all();
Redash::dashboards()->get($dashboardId);
Redash::dashboards()->create([
    // ...
]);
Redash::dashboards()->update($dashboardId, [
    // ...
]);
Redash::dashboards()->delete($dashboardId);

Jobs

Redash::jobs()->get($jobId);

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email igor.sgm@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 28
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-07-03