feat(api): definition of metric_type
feat(db): definition of metric_type
This commit is contained in:
parent
b190428780
commit
3281c4ecac
5 changed files with 85 additions and 17 deletions
|
|
@ -702,6 +702,17 @@ class MetricViewType(str, Enum):
|
|||
progress = "progress"
|
||||
|
||||
|
||||
class MetricType(str, Enum):
|
||||
timeseries = "timeseries"
|
||||
table = "table"
|
||||
|
||||
|
||||
# class MetricTypeTableGroupField(str, Enum):
|
||||
# users = "USERS"
|
||||
# click_rage = IssueType.click_rage
|
||||
# dead_click = IssueType.dead_click
|
||||
|
||||
|
||||
class CustomMetricRawPayloadSchema(BaseModel):
|
||||
startDate: int = Field(TimeUTC.now(-7))
|
||||
endDate: int = Field(TimeUTC.now())
|
||||
|
|
@ -719,6 +730,8 @@ class CustomMetricChartPayloadSchema(CustomMetricRawPayloadSchema):
|
|||
endDate: int = Field(TimeUTC.now())
|
||||
density: int = Field(7)
|
||||
viewType: MetricViewType = Field(MetricViewType.line_chart)
|
||||
metricType: MetricType = Field(MetricType.timeseries)
|
||||
groupField: Optional[Union[FilterType]] = Field(None)
|
||||
|
||||
|
||||
class CustomMetricChartPayloadSchema2(CustomMetricChartPayloadSchema):
|
||||
|
|
|
|||
26
ee/scripts/helm/db/init_dbs/postgresql/1.5.99/1.5.99.sql
Normal file
26
ee/scripts/helm/db/init_dbs/postgresql/1.5.99/1.5.99.sql
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
BEGIN;
|
||||
CREATE OR REPLACE FUNCTION openreplay_version()
|
||||
RETURNS text AS
|
||||
$$
|
||||
SELECT 'v1.5.X-ee'
|
||||
$$ LANGUAGE sql IMMUTABLE;
|
||||
|
||||
DO
|
||||
$$
|
||||
BEGIN
|
||||
IF NOT EXISTS(SELECT *
|
||||
FROM pg_type typ
|
||||
INNER JOIN pg_namespace nsp
|
||||
ON nsp.oid = typ.typnamespace
|
||||
WHERE nsp.nspname = current_schema()
|
||||
AND typ.typname = 'metric_type') THEN
|
||||
CREATE TYPE metric_type AS ENUM ('timeseries','table');
|
||||
END IF;
|
||||
END;
|
||||
$$
|
||||
LANGUAGE plpgsql;
|
||||
|
||||
ALTER TABLE metrics
|
||||
ADD COLUMN IF NOT EXISTS
|
||||
metric_type metric_type NOT NULL DEFAULT 'timeseries';
|
||||
COMMIT;
|
||||
|
|
@ -770,16 +770,18 @@ $$
|
|||
CREATE INDEX IF NOT EXISTS traces_user_id_idx ON traces (user_id);
|
||||
CREATE INDEX IF NOT EXISTS traces_tenant_id_idx ON traces (tenant_id);
|
||||
|
||||
CREATE TYPE metric_type AS ENUM ('timeseries','table');
|
||||
CREATE TABLE IF NOT EXISTS metrics
|
||||
(
|
||||
metric_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
name text NOT NULL,
|
||||
is_public boolean NOT NULL DEFAULT FALSE,
|
||||
active boolean NOT NULL DEFAULT TRUE,
|
||||
created_at timestamp default timezone('utc'::text, now()) not null,
|
||||
deleted_at timestamp
|
||||
metric_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
name text NOT NULL,
|
||||
is_public boolean NOT NULL DEFAULT FALSE,
|
||||
active boolean NOT NULL DEFAULT TRUE,
|
||||
created_at timestamp default timezone('utc'::text, now()) not null,
|
||||
deleted_at timestamp,
|
||||
metric_type metric_type NOT NULL DEFAULT 'timeseries'
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS metrics_user_id_is_public_idx ON public.metrics (user_id, is_public);
|
||||
CREATE TABLE IF NOT EXISTS metric_series
|
||||
|
|
|
|||
26
scripts/helm/db/init_dbs/postgresql/1.5.99/1.5.99.sql
Normal file
26
scripts/helm/db/init_dbs/postgresql/1.5.99/1.5.99.sql
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
BEGIN;
|
||||
CREATE OR REPLACE FUNCTION openreplay_version()
|
||||
RETURNS text AS
|
||||
$$
|
||||
SELECT 'v1.5.X'
|
||||
$$ LANGUAGE sql IMMUTABLE;
|
||||
|
||||
DO
|
||||
$$
|
||||
BEGIN
|
||||
IF NOT EXISTS(SELECT *
|
||||
FROM pg_type typ
|
||||
INNER JOIN pg_namespace nsp
|
||||
ON nsp.oid = typ.typnamespace
|
||||
WHERE nsp.nspname = current_schema()
|
||||
AND typ.typname = 'metric_type') THEN
|
||||
CREATE TYPE metric_type AS ENUM ('timeseries','table');
|
||||
END IF;
|
||||
END;
|
||||
$$
|
||||
LANGUAGE plpgsql;
|
||||
|
||||
ALTER TABLE metrics
|
||||
ADD COLUMN IF NOT EXISTS
|
||||
metric_type metric_type NOT NULL DEFAULT 'timeseries';
|
||||
COMMIT;
|
||||
|
|
@ -881,7 +881,6 @@ $$
|
|||
CREATE INDEX autocomplete_type_idx ON public.autocomplete (type);
|
||||
CREATE INDEX autocomplete_value_gin_idx ON public.autocomplete USING GIN (value gin_trgm_ops);
|
||||
|
||||
-- --- jobs.sql ---
|
||||
CREATE TYPE job_status AS ENUM ('scheduled','running','cancelled','failed','completed');
|
||||
CREATE TYPE job_action AS ENUM ('delete_user_data');
|
||||
CREATE TABLE jobs
|
||||
|
|
@ -901,16 +900,18 @@ $$
|
|||
CREATE INDEX jobs_start_at_idx ON jobs (start_at);
|
||||
CREATE INDEX jobs_project_id_idx ON jobs (project_id);
|
||||
|
||||
CREATE TYPE metric_type AS ENUM ('timeseries','table');
|
||||
CREATE TABLE metrics
|
||||
(
|
||||
metric_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
name text NOT NULL,
|
||||
is_public boolean NOT NULL DEFAULT FALSE,
|
||||
active boolean NOT NULL DEFAULT TRUE,
|
||||
created_at timestamp default timezone('utc'::text, now()) not null,
|
||||
deleted_at timestamp
|
||||
metric_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
name text NOT NULL,
|
||||
is_public boolean NOT NULL DEFAULT FALSE,
|
||||
active boolean NOT NULL DEFAULT TRUE,
|
||||
created_at timestamp default timezone('utc'::text, now()) not null,
|
||||
deleted_at timestamp,
|
||||
metric_type metric_type NOT NULL DEFAULT 'timeseries'
|
||||
);
|
||||
CREATE INDEX metrics_user_id_is_public_idx ON public.metrics (user_id, is_public);
|
||||
CREATE TABLE metric_series
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue