9
9
"time"
10
10
11
11
"github.com/grafana/google-sheets-datasource/pkg/models"
12
- "golang.org/x/oauth2"
13
12
14
13
"github.com/araddon/dateparse"
15
14
"github.com/davecgh/go-spew/spew"
@@ -18,6 +17,7 @@ import (
18
17
"github.com/grafana/grafana-plugin-sdk-go/data"
19
18
"github.com/grafana/grafana-plugin-sdk-go/experimental/errorsource"
20
19
"github.com/patrickmn/go-cache"
20
+ "golang.org/x/oauth2"
21
21
"google.golang.org/api/googleapi"
22
22
"google.golang.org/api/sheets/v4"
23
23
)
@@ -94,10 +94,13 @@ func (gs *GoogleSheets) GetSpreadsheets(ctx context.Context, config models.Datas
94
94
func (gs * GoogleSheets ) getSheetData (client client , qm * models.QueryModel ) (* sheets.GridData , map [string ]any , error ) {
95
95
cacheKey := qm .Spreadsheet + qm .Range
96
96
if item , expires , found := gs .Cache .GetWithExpiration (cacheKey ); found && qm .CacheDurationSeconds > 0 {
97
- return item .(* sheets.GridData ), map [string ]any {
98
- "hit" : true ,
99
- "expires" : expires .Unix (),
100
- }, nil
97
+ if gridData , ok := item .(* sheets.GridData ); ok {
98
+ return gridData , map [string ]any {
99
+ "hit" : true ,
100
+ "expires" : expires .Unix (),
101
+ }, nil
102
+ }
103
+ return nil , nil , errors .New ("invalid cache item not type of *sheets.GridData" )
101
104
}
102
105
103
106
result , err := client .GetSpreadsheet (qm .Spreadsheet , qm .Range , true )
0 commit comments