Skip to content

Commit

Permalink
Fix detail query
Browse files Browse the repository at this point in the history
  • Loading branch information
vkuznet committed Jan 18, 2021
1 parent 5b04280 commit 5ab568c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
17 changes: 11 additions & 6 deletions dbs/datasets.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"database/sql"
"fmt"
"net/http"
"strings"
)

// Datasets API
Expand All @@ -17,9 +18,13 @@ func (API) Datasets(params Record, w http.ResponseWriter) (int64, error) {
tmpl["Lfns"] = false
tmpl["Version"] = false
tmpl["ParentDataset"] = false
tmpl["Detail"] = false

// parse detail arugment
// detail, _ := getSingleValue(params, "detail")
detail, _ := getSingleValue(params, "detail")
if strings.ToLower(detail) != "true" {
tmpl["Detail"] = true
}

// parse dataset argument
datasets := getValues(params, "dataset")
Expand Down Expand Up @@ -154,11 +159,11 @@ func (API) Datasets(params Record, w http.ResponseWriter) (int64, error) {
}
cols := []string{"dataset_id", "dataset", "prep_id", "xtcrosssection", "creation_date", "create_by", "last_modification_date", "last_modified_by", "primary_ds_name", "primary_ds_type", "processed_ds_name", "data_tier_name", "dataset_access_type", "acquisition_era_name", "processing_version", "physics_group_name"}
vals := []interface{}{new(sql.NullInt64), new(sql.NullString), new(sql.NullString), new(sql.NullFloat64), new(sql.NullInt64), new(sql.NullString), new(sql.NullInt64), new(sql.NullString), new(sql.NullString), new(sql.NullString), new(sql.NullString), new(sql.NullString), new(sql.NullString), new(sql.NullString), new(sql.NullInt64), new(sql.NullString)}
// if strings.ToLower(detail) != "true" {
// stm = getSQL("datasets_short")
// cols = []string{"dataset"}
// vals = []interface{}{new(sql.NullString)}
// }
if strings.ToLower(detail) != "true" {
// stm = getSQL("datasets_short")
cols = []string{"dataset"}
vals = []interface{}{new(sql.NullString)}
}
stm = WhereClause(stm, conds)

// use generic query API to fetch the results from DB
Expand Down
4 changes: 4 additions & 0 deletions static/sql/datasets.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ SELECT DISTINCT
{{else}}
SELECT
{{end}}
{{if .Detail}}
D.DATASET_ID, D.DATASET, D.PREP_ID,
D.XTCROSSSECTION,
D.CREATION_DATE, D.CREATE_BY,
Expand All @@ -26,6 +27,9 @@ SELECT
,PSH.PSET_HASH,
,AEX.APP_NAME
{{end}}
{{else}}
D.DATASET
{{end}}

FROM {{.Owner}}.DATASETS D
JOIN {{.Owner}}.PRIMARY_DATASETS P ON P.PRIMARY_DS_ID = D.PRIMARY_DS_ID
Expand Down

0 comments on commit 5ab568c

Please sign in to comment.