diff --git a/measure-backend/measure-go/measure/app.go b/measure-backend/measure-go/measure/app.go index 1a17a3ea3..f0ad78b33 100644 --- a/measure-backend/measure-go/measure/app.go +++ b/measure-backend/measure-go/measure/app.go @@ -24,7 +24,6 @@ select apps.unique_identifier, apps.platform, apps.first_version, - apps.latest_version, apps.first_seen_at, apps.onboarded, apps.onboarded_at, @@ -41,19 +40,18 @@ where apps.id = $1 and apps.team_id = $2; ` type App struct { - ID *uuid.UUID `json:"id"` - TeamId uuid.UUID `json:"team_id"` - AppName string `json:"name" binding:"required"` - UniqueId string `json:"unique_identifier"` - Platform string `json:"platform"` - APIKey *APIKey `json:"api_key"` - firstVersion string `json:"first_version"` - latestVersion string `json:"latest_version"` - firstSeenAt time.Time `json:"first_seen_at"` - Onboarded bool `json:"onboarded"` - OnboardedAt time.Time `json:"onboarded_at"` - CreatedAt time.Time `json:"created_at"` - UpdatedAt time.Time `json:"updated_at"` + ID *uuid.UUID `json:"id"` + TeamId uuid.UUID `json:"team_id"` + AppName string `json:"name" binding:"required"` + UniqueId string `json:"unique_identifier"` + Platform string `json:"platform"` + APIKey *APIKey `json:"api_key"` + firstVersion string `json:"first_version"` + firstSeenAt time.Time `json:"first_seen_at"` + Onboarded bool `json:"onboarded"` + OnboardedAt time.Time `json:"onboarded_at"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` } func (a App) MarshalJSON() ([]byte, error) { @@ -136,19 +134,17 @@ func (a *App) get() (*App, error) { var uniqueId pgtype.Text var platform pgtype.Text var firstVersion pgtype.Text - var latestVersion pgtype.Text stmt := sqlf.PostgreSQL. Select("onboarded", nil). Select("unique_identifier", nil). Select("platform", nil). Select("first_version", nil). - Select("latest_version", nil). From("apps"). Where("id = ?", nil) defer stmt.Close() - if err := server.Server.PgPool.QueryRow(context.Background(), stmt.String(), a.ID).Scan(&onboarded, &uniqueId, &platform, &firstVersion, &latestVersion); err != nil { + if err := server.Server.PgPool.QueryRow(context.Background(), stmt.String(), a.ID).Scan(&onboarded, &uniqueId, &platform, &firstVersion); err != nil { if errors.Is(err, pgx.ErrNoRows) { return nil, nil } else { @@ -174,12 +170,6 @@ func (a *App) get() (*App, error) { a.firstVersion = "" } - if latestVersion.Valid { - a.latestVersion = latestVersion.String - } else { - a.latestVersion = "" - } - return a, nil } @@ -188,7 +178,6 @@ func (a *App) getWithTeam(id uuid.UUID) (*App, error) { var uniqueId pgtype.Text var platform pgtype.Text var firstVersion pgtype.Text - var latestVersion pgtype.Text var firstSeenAt pgtype.Timestamptz var onboarded pgtype.Bool var onboardedAt pgtype.Timestamptz @@ -199,7 +188,7 @@ func (a *App) getWithTeam(id uuid.UUID) (*App, error) { apiKey := new(APIKey) - if err := server.Server.PgPool.QueryRow(context.Background(), queryGetApp, id, a.TeamId).Scan(&appName, &uniqueId, &platform, &firstVersion, &latestVersion, &firstSeenAt, &onboarded, &onboardedAt, &apiKey.keyPrefix, &apiKey.keyValue, &apiKey.checksum, &apiKeyLastSeen, &apiKeyCreatedAt, &createdAt, &updatedAt); err != nil { + if err := server.Server.PgPool.QueryRow(context.Background(), queryGetApp, id, a.TeamId).Scan(&appName, &uniqueId, &platform, &firstVersion, &firstSeenAt, &onboarded, &onboardedAt, &apiKey.keyPrefix, &apiKey.keyValue, &apiKey.checksum, &apiKeyLastSeen, &apiKeyCreatedAt, &createdAt, &updatedAt); err != nil { if errors.Is(err, pgx.ErrNoRows) { return nil, nil } else { @@ -233,12 +222,6 @@ func (a *App) getWithTeam(id uuid.UUID) (*App, error) { a.Onboarded = onboarded.Bool } - if latestVersion.Valid { - a.latestVersion = latestVersion.String - } else { - a.latestVersion = "" - } - if firstSeenAt.Valid { a.firstSeenAt = firstSeenAt.Time } @@ -275,14 +258,13 @@ func (a *App) Onboard(tx pgx.Tx, uniqueIdentifier, platform, firstVersion string Set("unique_identifier", nil). Set("platform", nil). Set("first_version", nil). - Set("latest_version", nil). Set("first_seen_at", nil). Set("updated_at", nil). Where("id = ?", nil) defer stmt.Close() - _, err := tx.Exec(context.Background(), stmt.String(), true, uniqueIdentifier, platform, firstVersion, firstVersion, now, now, a.ID) + _, err := tx.Exec(context.Background(), stmt.String(), true, uniqueIdentifier, platform, firstVersion, now, now, a.ID) if err != nil { return err } diff --git a/measure-backend/measure-go/measure/team.go b/measure-backend/measure-go/measure/team.go index 49444b560..5dba52b4a 100644 --- a/measure-backend/measure-go/measure/team.go +++ b/measure-backend/measure-go/measure/team.go @@ -27,7 +27,6 @@ select apps.unique_identifier, apps.platform, apps.first_version, - apps.latest_version, apps.first_seen_at, apps.onboarded, apps.onboarded_at, @@ -88,7 +87,6 @@ func (t *Team) getApps() ([]App, error) { var uniqueId pgtype.Text var platform pgtype.Text var firstVersion pgtype.Text - var latestVersion pgtype.Text var firstSeenAt pgtype.Timestamptz var onboardedAt pgtype.Timestamptz var apiKeyLastSeen pgtype.Timestamptz @@ -96,7 +94,7 @@ func (t *Team) getApps() ([]App, error) { apiKey := new(APIKey) - if err := rows.Scan(&a.ID, &a.AppName, &a.TeamId, &uniqueId, &platform, &firstVersion, &latestVersion, &firstSeenAt, &a.Onboarded, &onboardedAt, &apiKey.keyPrefix, &apiKey.keyValue, &apiKey.checksum, &apiKeyLastSeen, &apiKeyCreatedAt, &a.CreatedAt, &a.UpdatedAt); err != nil { + if err := rows.Scan(&a.ID, &a.AppName, &a.TeamId, &uniqueId, &platform, &firstVersion, &firstSeenAt, &a.Onboarded, &onboardedAt, &apiKey.keyPrefix, &apiKey.keyValue, &apiKey.checksum, &apiKeyLastSeen, &apiKeyCreatedAt, &a.CreatedAt, &a.UpdatedAt); err != nil { return nil, err } @@ -118,12 +116,6 @@ func (t *Team) getApps() ([]App, error) { a.firstVersion = "" } - if latestVersion.Valid { - a.latestVersion = latestVersion.String - } else { - a.latestVersion = "" - } - if firstSeenAt.Valid { a.firstSeenAt = firstSeenAt.Time } diff --git a/self-host/postgres/20231117010526_create-apps-relation.sql b/self-host/postgres/20231117010526_create-apps-relation.sql index 83d2b9e65..e667d3d51 100644 --- a/self-host/postgres/20231117010526_create-apps-relation.sql +++ b/self-host/postgres/20231117010526_create-apps-relation.sql @@ -6,7 +6,6 @@ create table if not exists public.apps ( app_name varchar(512), platform varchar(256) check (platform in ('ios', 'android', 'flutter', 'react-native', 'unity')), first_version varchar(128), - latest_version varchar(128), first_seen_at timestamptz, onboarded boolean default false, onboarded_at timestamptz, @@ -20,7 +19,6 @@ comment on column public.apps.unique_identifier is 'unique id lingua franca to a comment on column public.apps.app_name is 'name of app lingua franca to app creator'; comment on column public.apps.platform is 'platform of the app, like iOS, Android, Flutter'; comment on column public.apps.first_version is 'first version of the app as per ingested sessions from it'; -comment on column public.apps.latest_version is 'latest version of the app as per ingested sessions from it'; comment on column public.apps.first_seen_at is 'utc timestamp as per the nascent ingested session'; comment on column public.apps.onboarded is 'app is considered onboarded once it receives the first session'; comment on column public.apps.onboarded_at is 'utc timestamp at the time of receiving first session'; diff --git a/self-host/postgres/schema.sql b/self-host/postgres/schema.sql index cabf8aafc..be3110aa5 100644 --- a/self-host/postgres/schema.sql +++ b/self-host/postgres/schema.sql @@ -173,7 +173,6 @@ CREATE TABLE public.apps ( app_name character varying(512), platform character varying(256), first_version character varying(128), - latest_version character varying(128), first_seen_at timestamp with time zone, onboarded boolean DEFAULT false, onboarded_at timestamp with time zone, @@ -225,13 +224,6 @@ COMMENT ON COLUMN public.apps.platform IS 'platform of the app, like iOS, Androi COMMENT ON COLUMN public.apps.first_version IS 'first version of the app as per ingested sessions from it'; --- --- Name: COLUMN apps.latest_version; Type: COMMENT; Schema: public; Owner: - --- - -COMMENT ON COLUMN public.apps.latest_version IS 'latest version of the app as per ingested sessions from it'; - - -- -- Name: COLUMN apps.first_seen_at; Type: COMMENT; Schema: public; Owner: - --