完善活动运营域与联调标准化
This commit is contained in:
@@ -23,20 +23,54 @@ type Event struct {
|
||||
ManifestChecksum *string
|
||||
RouteCode *string
|
||||
ReleasePayloadJSON *string
|
||||
RuntimeBindingID *string
|
||||
PlacePublicID *string
|
||||
PlaceName *string
|
||||
MapAssetPublicID *string
|
||||
MapAssetName *string
|
||||
TileReleasePublicID *string
|
||||
CourseSetPublicID *string
|
||||
CourseVariantID *string
|
||||
CourseVariantName *string
|
||||
RuntimeRouteCode *string
|
||||
PresentationID *string
|
||||
PresentationName *string
|
||||
PresentationType *string
|
||||
ContentBundleID *string
|
||||
ContentBundleName *string
|
||||
ContentEntryURL *string
|
||||
ContentAssetRootURL *string
|
||||
}
|
||||
|
||||
type EventRelease struct {
|
||||
ID string
|
||||
PublicID string
|
||||
EventID string
|
||||
ReleaseNo int
|
||||
ConfigLabel string
|
||||
ManifestURL string
|
||||
ManifestChecksum *string
|
||||
RouteCode *string
|
||||
BuildID *string
|
||||
Status string
|
||||
PublishedAt time.Time
|
||||
ID string
|
||||
PublicID string
|
||||
EventID string
|
||||
ReleaseNo int
|
||||
ConfigLabel string
|
||||
ManifestURL string
|
||||
ManifestChecksum *string
|
||||
RouteCode *string
|
||||
BuildID *string
|
||||
Status string
|
||||
PublishedAt time.Time
|
||||
RuntimeBindingID *string
|
||||
PlacePublicID *string
|
||||
PlaceName *string
|
||||
MapAssetPublicID *string
|
||||
MapAssetName *string
|
||||
TileReleaseID *string
|
||||
CourseSetID *string
|
||||
CourseVariantID *string
|
||||
CourseVariantName *string
|
||||
RuntimeRouteCode *string
|
||||
PresentationID *string
|
||||
PresentationName *string
|
||||
PresentationType *string
|
||||
ContentBundleID *string
|
||||
ContentBundleName *string
|
||||
ContentEntryURL *string
|
||||
ContentAssetURL *string
|
||||
}
|
||||
|
||||
type CreateGameSessionParams struct {
|
||||
@@ -85,9 +119,34 @@ func (s *Store) GetEventByPublicID(ctx context.Context, eventPublicID string) (*
|
||||
er.manifest_url,
|
||||
er.manifest_checksum_sha256,
|
||||
er.route_code,
|
||||
er.payload_jsonb::text
|
||||
er.payload_jsonb::text,
|
||||
mrb.runtime_binding_public_id,
|
||||
p.place_public_id,
|
||||
p.name,
|
||||
ma.map_asset_public_id,
|
||||
ma.name,
|
||||
tr.tile_release_public_id,
|
||||
cset.course_set_public_id,
|
||||
cv.course_variant_public_id,
|
||||
cv.name,
|
||||
cv.route_code,
|
||||
ep.presentation_public_id,
|
||||
ep.name,
|
||||
ep.presentation_type,
|
||||
cb.content_bundle_public_id,
|
||||
cb.name,
|
||||
cb.entry_url,
|
||||
cb.asset_root_url
|
||||
FROM events e
|
||||
LEFT JOIN event_releases er ON er.id = e.current_release_id
|
||||
LEFT JOIN map_runtime_bindings mrb ON mrb.id = er.runtime_binding_id
|
||||
LEFT JOIN places p ON p.id = mrb.place_id
|
||||
LEFT JOIN map_assets ma ON ma.id = mrb.map_asset_id
|
||||
LEFT JOIN tile_releases tr ON tr.id = mrb.tile_release_id
|
||||
LEFT JOIN course_sets cset ON cset.id = mrb.course_set_id
|
||||
LEFT JOIN course_variants cv ON cv.id = mrb.course_variant_id
|
||||
LEFT JOIN event_presentations ep ON ep.id = er.presentation_id
|
||||
LEFT JOIN content_bundles cb ON cb.id = er.content_bundle_id
|
||||
WHERE e.event_public_id = $1
|
||||
LIMIT 1
|
||||
`, eventPublicID)
|
||||
@@ -107,6 +166,23 @@ func (s *Store) GetEventByPublicID(ctx context.Context, eventPublicID string) (*
|
||||
&event.ManifestChecksum,
|
||||
&event.RouteCode,
|
||||
&event.ReleasePayloadJSON,
|
||||
&event.RuntimeBindingID,
|
||||
&event.PlacePublicID,
|
||||
&event.PlaceName,
|
||||
&event.MapAssetPublicID,
|
||||
&event.MapAssetName,
|
||||
&event.TileReleasePublicID,
|
||||
&event.CourseSetPublicID,
|
||||
&event.CourseVariantID,
|
||||
&event.CourseVariantName,
|
||||
&event.RuntimeRouteCode,
|
||||
&event.PresentationID,
|
||||
&event.PresentationName,
|
||||
&event.PresentationType,
|
||||
&event.ContentBundleID,
|
||||
&event.ContentBundleName,
|
||||
&event.ContentEntryURL,
|
||||
&event.ContentAssetRootURL,
|
||||
)
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return nil, nil
|
||||
@@ -132,9 +208,34 @@ func (s *Store) GetEventByID(ctx context.Context, eventID string) (*Event, error
|
||||
er.manifest_url,
|
||||
er.manifest_checksum_sha256,
|
||||
er.route_code,
|
||||
er.payload_jsonb::text
|
||||
er.payload_jsonb::text,
|
||||
mrb.runtime_binding_public_id,
|
||||
p.place_public_id,
|
||||
p.name,
|
||||
ma.map_asset_public_id,
|
||||
ma.name,
|
||||
tr.tile_release_public_id,
|
||||
cset.course_set_public_id,
|
||||
cv.course_variant_public_id,
|
||||
cv.name,
|
||||
cv.route_code,
|
||||
ep.presentation_public_id,
|
||||
ep.name,
|
||||
ep.presentation_type,
|
||||
cb.content_bundle_public_id,
|
||||
cb.name,
|
||||
cb.entry_url,
|
||||
cb.asset_root_url
|
||||
FROM events e
|
||||
LEFT JOIN event_releases er ON er.id = e.current_release_id
|
||||
LEFT JOIN map_runtime_bindings mrb ON mrb.id = er.runtime_binding_id
|
||||
LEFT JOIN places p ON p.id = mrb.place_id
|
||||
LEFT JOIN map_assets ma ON ma.id = mrb.map_asset_id
|
||||
LEFT JOIN tile_releases tr ON tr.id = mrb.tile_release_id
|
||||
LEFT JOIN course_sets cset ON cset.id = mrb.course_set_id
|
||||
LEFT JOIN course_variants cv ON cv.id = mrb.course_variant_id
|
||||
LEFT JOIN event_presentations ep ON ep.id = er.presentation_id
|
||||
LEFT JOIN content_bundles cb ON cb.id = er.content_bundle_id
|
||||
WHERE e.id = $1
|
||||
LIMIT 1
|
||||
`, eventID)
|
||||
@@ -154,6 +255,23 @@ func (s *Store) GetEventByID(ctx context.Context, eventID string) (*Event, error
|
||||
&event.ManifestChecksum,
|
||||
&event.RouteCode,
|
||||
&event.ReleasePayloadJSON,
|
||||
&event.RuntimeBindingID,
|
||||
&event.PlacePublicID,
|
||||
&event.PlaceName,
|
||||
&event.MapAssetPublicID,
|
||||
&event.MapAssetName,
|
||||
&event.TileReleasePublicID,
|
||||
&event.CourseSetPublicID,
|
||||
&event.CourseVariantID,
|
||||
&event.CourseVariantName,
|
||||
&event.RuntimeRouteCode,
|
||||
&event.PresentationID,
|
||||
&event.PresentationName,
|
||||
&event.PresentationType,
|
||||
&event.ContentBundleID,
|
||||
&event.ContentBundleName,
|
||||
&event.ContentEntryURL,
|
||||
&event.ContentAssetRootURL,
|
||||
)
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return nil, nil
|
||||
@@ -168,7 +286,7 @@ func (s *Store) NextEventReleaseNo(ctx context.Context, eventID string) (int, er
|
||||
var next int
|
||||
if err := s.pool.QueryRow(ctx, `
|
||||
SELECT COALESCE(MAX(release_no), 0) + 1
|
||||
FROM event_releases
|
||||
FROM event_releases er
|
||||
WHERE event_id = $1
|
||||
`, eventID).Scan(&next); err != nil {
|
||||
return 0, fmt.Errorf("next event release no: %w", err)
|
||||
@@ -185,6 +303,9 @@ type CreateEventReleaseParams struct {
|
||||
ManifestChecksum *string
|
||||
RouteCode *string
|
||||
BuildID *string
|
||||
RuntimeBindingID *string
|
||||
PresentationID *string
|
||||
ContentBundleID *string
|
||||
Status string
|
||||
PayloadJSON string
|
||||
}
|
||||
@@ -200,12 +321,15 @@ func (s *Store) CreateEventRelease(ctx context.Context, tx Tx, params CreateEven
|
||||
manifest_checksum_sha256,
|
||||
route_code,
|
||||
build_id,
|
||||
runtime_binding_id,
|
||||
presentation_id,
|
||||
content_bundle_id,
|
||||
status,
|
||||
payload_jsonb
|
||||
)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10::jsonb)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13::jsonb)
|
||||
RETURNING id, release_public_id, event_id, release_no, config_label, manifest_url, manifest_checksum_sha256, route_code, build_id, status, published_at
|
||||
`, params.PublicID, params.EventID, params.ReleaseNo, params.ConfigLabel, params.ManifestURL, params.ManifestChecksum, params.RouteCode, params.BuildID, params.Status, params.PayloadJSON)
|
||||
`, params.PublicID, params.EventID, params.ReleaseNo, params.ConfigLabel, params.ManifestURL, params.ManifestChecksum, params.RouteCode, params.BuildID, params.RuntimeBindingID, params.PresentationID, params.ContentBundleID, params.Status, params.PayloadJSON)
|
||||
|
||||
var item EventRelease
|
||||
if err := row.Scan(
|
||||
@@ -284,10 +408,46 @@ func (s *Store) ListEventReleasesByEventID(ctx context.Context, eventID string,
|
||||
limit = 20
|
||||
}
|
||||
rows, err := s.pool.Query(ctx, `
|
||||
SELECT id, release_public_id, event_id, release_no, config_label, manifest_url, manifest_checksum_sha256, route_code, build_id, status, published_at
|
||||
FROM event_releases
|
||||
WHERE event_id = $1
|
||||
ORDER BY release_no DESC
|
||||
SELECT
|
||||
er.id,
|
||||
er.release_public_id,
|
||||
er.event_id,
|
||||
er.release_no,
|
||||
er.config_label,
|
||||
er.manifest_url,
|
||||
er.manifest_checksum_sha256,
|
||||
er.route_code,
|
||||
er.build_id,
|
||||
er.status,
|
||||
er.published_at,
|
||||
mrb.runtime_binding_public_id,
|
||||
p.place_public_id,
|
||||
p.name,
|
||||
ma.map_asset_public_id,
|
||||
ma.name,
|
||||
tr.tile_release_public_id,
|
||||
cset.course_set_public_id,
|
||||
cv.course_variant_public_id,
|
||||
cv.name,
|
||||
cv.route_code,
|
||||
ep.presentation_public_id,
|
||||
ep.name,
|
||||
ep.presentation_type,
|
||||
cb.content_bundle_public_id,
|
||||
cb.name,
|
||||
cb.entry_url,
|
||||
cb.asset_root_url
|
||||
FROM event_releases er
|
||||
LEFT JOIN map_runtime_bindings mrb ON mrb.id = er.runtime_binding_id
|
||||
LEFT JOIN places p ON p.id = mrb.place_id
|
||||
LEFT JOIN map_assets ma ON ma.id = mrb.map_asset_id
|
||||
LEFT JOIN tile_releases tr ON tr.id = mrb.tile_release_id
|
||||
LEFT JOIN course_sets cset ON cset.id = mrb.course_set_id
|
||||
LEFT JOIN course_variants cv ON cv.id = mrb.course_variant_id
|
||||
LEFT JOIN event_presentations ep ON ep.id = er.presentation_id
|
||||
LEFT JOIN content_bundles cb ON cb.id = er.content_bundle_id
|
||||
WHERE er.event_id = $1
|
||||
ORDER BY er.release_no DESC
|
||||
LIMIT $2
|
||||
`, eventID, limit)
|
||||
if err != nil {
|
||||
@@ -311,9 +471,45 @@ func (s *Store) ListEventReleasesByEventID(ctx context.Context, eventID string,
|
||||
|
||||
func (s *Store) GetEventReleaseByPublicID(ctx context.Context, releasePublicID string) (*EventRelease, error) {
|
||||
row := s.pool.QueryRow(ctx, `
|
||||
SELECT id, release_public_id, event_id, release_no, config_label, manifest_url, manifest_checksum_sha256, route_code, build_id, status, published_at
|
||||
FROM event_releases
|
||||
WHERE release_public_id = $1
|
||||
SELECT
|
||||
er.id,
|
||||
er.release_public_id,
|
||||
er.event_id,
|
||||
er.release_no,
|
||||
er.config_label,
|
||||
er.manifest_url,
|
||||
er.manifest_checksum_sha256,
|
||||
er.route_code,
|
||||
er.build_id,
|
||||
er.status,
|
||||
er.published_at,
|
||||
mrb.runtime_binding_public_id,
|
||||
p.place_public_id,
|
||||
p.name,
|
||||
ma.map_asset_public_id,
|
||||
ma.name,
|
||||
tr.tile_release_public_id,
|
||||
cset.course_set_public_id,
|
||||
cv.course_variant_public_id,
|
||||
cv.name,
|
||||
cv.route_code,
|
||||
ep.presentation_public_id,
|
||||
ep.name,
|
||||
ep.presentation_type,
|
||||
cb.content_bundle_public_id,
|
||||
cb.name,
|
||||
cb.entry_url,
|
||||
cb.asset_root_url
|
||||
FROM event_releases er
|
||||
LEFT JOIN map_runtime_bindings mrb ON mrb.id = er.runtime_binding_id
|
||||
LEFT JOIN places p ON p.id = mrb.place_id
|
||||
LEFT JOIN map_assets ma ON ma.id = mrb.map_asset_id
|
||||
LEFT JOIN tile_releases tr ON tr.id = mrb.tile_release_id
|
||||
LEFT JOIN course_sets cset ON cset.id = mrb.course_set_id
|
||||
LEFT JOIN course_variants cv ON cv.id = mrb.course_variant_id
|
||||
LEFT JOIN event_presentations ep ON ep.id = er.presentation_id
|
||||
LEFT JOIN content_bundles cb ON cb.id = er.content_bundle_id
|
||||
WHERE er.release_public_id = $1
|
||||
LIMIT 1
|
||||
`, releasePublicID)
|
||||
|
||||
@@ -330,6 +526,23 @@ func (s *Store) GetEventReleaseByPublicID(ctx context.Context, releasePublicID s
|
||||
&item.BuildID,
|
||||
&item.Status,
|
||||
&item.PublishedAt,
|
||||
&item.RuntimeBindingID,
|
||||
&item.PlacePublicID,
|
||||
&item.PlaceName,
|
||||
&item.MapAssetPublicID,
|
||||
&item.MapAssetName,
|
||||
&item.TileReleaseID,
|
||||
&item.CourseSetID,
|
||||
&item.CourseVariantID,
|
||||
&item.CourseVariantName,
|
||||
&item.RuntimeRouteCode,
|
||||
&item.PresentationID,
|
||||
&item.PresentationName,
|
||||
&item.PresentationType,
|
||||
&item.ContentBundleID,
|
||||
&item.ContentBundleName,
|
||||
&item.ContentEntryURL,
|
||||
&item.ContentAssetURL,
|
||||
)
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return nil, nil
|
||||
@@ -354,9 +567,37 @@ func scanEventReleaseFromRows(rows pgx.Rows) (*EventRelease, error) {
|
||||
&item.BuildID,
|
||||
&item.Status,
|
||||
&item.PublishedAt,
|
||||
&item.RuntimeBindingID,
|
||||
&item.PlacePublicID,
|
||||
&item.PlaceName,
|
||||
&item.MapAssetPublicID,
|
||||
&item.MapAssetName,
|
||||
&item.TileReleaseID,
|
||||
&item.CourseSetID,
|
||||
&item.CourseVariantID,
|
||||
&item.CourseVariantName,
|
||||
&item.RuntimeRouteCode,
|
||||
&item.PresentationID,
|
||||
&item.PresentationName,
|
||||
&item.PresentationType,
|
||||
&item.ContentBundleID,
|
||||
&item.ContentBundleName,
|
||||
&item.ContentEntryURL,
|
||||
&item.ContentAssetURL,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("scan event release row: %w", err)
|
||||
}
|
||||
return &item, nil
|
||||
}
|
||||
|
||||
func (s *Store) SetEventReleaseRuntimeBinding(ctx context.Context, tx Tx, releaseID string, runtimeBindingID *string) error {
|
||||
if _, err := tx.Exec(ctx, `
|
||||
UPDATE event_releases
|
||||
SET runtime_binding_id = $2
|
||||
WHERE id = $1
|
||||
`, releaseID, runtimeBindingID); err != nil {
|
||||
return fmt.Errorf("set event release runtime binding: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user