(ctx context.Context)
| 64 | var viewRe = regexp.MustCompile(`^[a-z0-9]{1,20}$`) |
| 65 | |
| 66 | func DBGetBlockViewCounts(ctx context.Context) (map[string]int, error) { |
| 67 | return WithTxRtn(ctx, func(tx *TxWrap) (map[string]int, error) { |
| 68 | query := `SELECT COALESCE(json_extract(data, '$.meta.view'), '') AS view FROM db_block` |
| 69 | views := tx.SelectStrings(query) |
| 70 | rtn := make(map[string]int) |
| 71 | for _, view := range views { |
| 72 | if view == "" { |
| 73 | continue |
| 74 | } |
| 75 | if !viewRe.MatchString(view) { |
| 76 | continue |
| 77 | } |
| 78 | rtn[view]++ |
| 79 | } |
| 80 | return rtn, nil |
| 81 | }) |
| 82 | } |
| 83 | |
| 84 | type idDataType struct { |
| 85 | OId string |
no test coverage detected