Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jacek fixes #34

Merged
merged 2 commits into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docker/cloudflared.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: "3.7"
services:
cloudflared:
image: cloudflare/cloudflared:latest
env_file:
- .env
restart: unless-stopped
command:
- "tunnel"
- "--no-autoupdate"
- "run"
- "--token"
- ${CLOUDFLARED_TOKEN}
13 changes: 10 additions & 3 deletions docker/opensearch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ services:
- QUESMA_logging_path=/var/quesma/logs
- QUESMA_CONFIG_FILE=/config/local-dev.yaml
depends_on:
clickhouse:
condition: service_healthy
clean-clickhouse:
condition: service_completed_successfully
opensearch:
condition: service_healthy
ports:
Expand Down Expand Up @@ -127,4 +127,11 @@ services:
interval: 1s
start_period: 1m
timeout: 1s
# TODO: add clean, skip for now
clean-clickhouse:
build: clean-clickhouse
depends_on:
clickhouse:
condition: service_healthy
restart: "no"
volumes:
- ./mitmproxy:/var/mitmproxy
8 changes: 7 additions & 1 deletion docker/quesma/config/local-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,10 @@ indexes:
timestamp:
source: "@timestamp"
target: "created_at"
fullTextFields: [ "body", "title" ]
fullTextFields: [ "body", "title" ]
opensearch_dashboards_sample_data_ecommerce:
enabled: true
opensearch_dashboards_sample_data_flights:
enabled: true
opensearch_dashboards_sample_data_logs:
enabled: true
2 changes: 1 addition & 1 deletion quesma/model/metrics_aggregations/top_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (query TopMetrics) TranslateSqlResponseToJson(rows []model.QueryResultRow,
sortVal := row.Cols[lastIndex].Value
for _, col := range valuesForMetrics[level:] {
colName, _ := strings.CutPrefix(col.ColName, "windowed_")
metrics[colName] = col.ExtractValue(context.TODO()) // CHANGE IT AFTER PART 2 MERGE!! ENTER REAL CONTEXT FROM THE query
metrics[colName] = col.ExtractValue(query.ctx) // CHANGE IT AFTER PART 2 MERGE!! ENTER REAL CONTEXT FROM THE query
}
elem := model.JsonMap{
"sort": []interface{}{sortVal},
Expand Down
5 changes: 2 additions & 3 deletions quesma/model/query_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ type QueryResultCol struct {
}

type QueryResultRow struct {
ctx context.Context
Index string
Cols []QueryResultCol
}
Expand Down Expand Up @@ -110,13 +109,13 @@ func (c QueryResultCol) ExtractValue(ctx context.Context) any {
return c.Value
}

func (r QueryResultRow) String() string {
func (r QueryResultRow) String(ctx context.Context) string {
str := strings.Builder{}
str.WriteString(util.Indent(1) + "{\n")
numCols := len(r.Cols)
i := 0
for _, col := range r.Cols {
str.WriteString(util.Indent(2) + col.String(r.ctx))
str.WriteString(util.Indent(2) + col.String(ctx))
if i < numCols-1 {
str.WriteString(",")
}
Expand Down
2 changes: 1 addition & 1 deletion quesma/queryparser/query_translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (cw *ClickhouseQueryTranslator) makeSearchResponseNormal(ResultSet []model.
for i, row := range ResultSet {
hits[i] = model.SearchHit{
Index: row.Index,
Source: []byte(row.String()),
Source: []byte(row.String(cw.Ctx)),
Fields: make(map[string][]interface{}),
Highlight: make(map[string][]string),
}
Expand Down
Loading