feat: implement geometry and battle replay repositories, services, and associated database schemas
Build and Release / release (push) Successful in 1m23s
Build and Release / release (push) Successful in 1m23s
This commit is contained in:
@@ -253,6 +253,7 @@ func (r *battleReplayRepository) Create(ctx context.Context, params sqlc.CreateB
|
||||
|
||||
_ = r.c.Del(ctx, cache.Key("battle_replay:project", entity.ProjectID))
|
||||
_ = r.c.Del(ctx, cache.Key("battle_replay:geometry", entity.GeometryID))
|
||||
_ = r.c.Del(ctx, cache.Key("geometry:id", entity.GeometryID))
|
||||
|
||||
return entity, nil
|
||||
}
|
||||
@@ -265,10 +266,16 @@ func (r *battleReplayRepository) Update(ctx context.Context, params sqlc.UpdateB
|
||||
|
||||
entity := r.rowToEntity(row)
|
||||
_ = r.c.Del(ctx, cache.Key("battle_replay:id", entity.ID))
|
||||
_ = r.c.Del(ctx, cache.Key("battle_replay:geometry", entity.GeometryID))
|
||||
_ = r.c.Del(ctx, cache.Key("geometry:id", entity.GeometryID))
|
||||
return entity, nil
|
||||
}
|
||||
|
||||
func (r *battleReplayRepository) Delete(ctx context.Context, id pgtype.UUID) error {
|
||||
if item, err := r.GetByID(ctx, id); err == nil && item != nil {
|
||||
_ = r.c.Del(ctx, cache.Key("geometry:id", item.GeometryID))
|
||||
_ = r.c.Del(ctx, cache.Key("battle_replay:geometry", item.GeometryID))
|
||||
}
|
||||
err := r.q.DeleteBattleReplay(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -278,6 +285,20 @@ func (r *battleReplayRepository) Delete(ctx context.Context, id pgtype.UUID) err
|
||||
}
|
||||
|
||||
func (r *battleReplayRepository) DeleteByIDs(ctx context.Context, ids []pgtype.UUID) error {
|
||||
if len(ids) > 0 {
|
||||
strIDs := make([]string, len(ids))
|
||||
for i, id := range ids {
|
||||
strIDs[i] = convert.UUIDToString(id)
|
||||
}
|
||||
if items, err := r.GetByIDs(ctx, strIDs); err == nil {
|
||||
for _, item := range items {
|
||||
if item != nil {
|
||||
_ = r.c.Del(ctx, cache.Key("geometry:id", item.GeometryID))
|
||||
_ = r.c.Del(ctx, cache.Key("battle_replay:geometry", item.GeometryID))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
err := r.q.DeleteBattleReplaysByIDs(ctx, ids)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -105,6 +105,7 @@ func (r *geometryRepository) getByIDsWithFallback(ctx context.Context, ids []str
|
||||
},
|
||||
ProjectID: convert.UUIDToString(row.ProjectID),
|
||||
IsDeleted: row.IsDeleted,
|
||||
ReplayIDs: convert.ListUUIDToString(row.ReplayIds),
|
||||
CreatedAt: convert.TimeToPtr(row.CreatedAt),
|
||||
UpdatedAt: convert.TimeToPtr(row.UpdatedAt),
|
||||
}
|
||||
@@ -167,6 +168,7 @@ func (r *geometryRepository) GetByID(ctx context.Context, id pgtype.UUID) (*mode
|
||||
},
|
||||
ProjectID: convert.UUIDToString(row.ProjectID),
|
||||
IsDeleted: row.IsDeleted,
|
||||
ReplayIDs: convert.ListUUIDToString(row.ReplayIds),
|
||||
CreatedAt: convert.TimeToPtr(row.CreatedAt),
|
||||
UpdatedAt: convert.TimeToPtr(row.UpdatedAt),
|
||||
}
|
||||
@@ -210,6 +212,7 @@ func (r *geometryRepository) Search(ctx context.Context, params sqlc.SearchGeome
|
||||
},
|
||||
ProjectID: convert.UUIDToString(row.ProjectID),
|
||||
IsDeleted: row.IsDeleted,
|
||||
ReplayIDs: convert.ListUUIDToString(row.ReplayIds),
|
||||
CreatedAt: convert.TimeToPtr(row.CreatedAt),
|
||||
UpdatedAt: convert.TimeToPtr(row.UpdatedAt),
|
||||
}
|
||||
@@ -342,6 +345,7 @@ func (r *geometryRepository) GetByProjectID(ctx context.Context, projectID pgtyp
|
||||
},
|
||||
ProjectID: convert.UUIDToString(row.ProjectID),
|
||||
IsDeleted: row.IsDeleted,
|
||||
ReplayIDs: convert.ListUUIDToString(row.ReplayIds),
|
||||
CreatedAt: convert.TimeToPtr(row.CreatedAt),
|
||||
UpdatedAt: convert.TimeToPtr(row.UpdatedAt),
|
||||
}
|
||||
@@ -394,6 +398,7 @@ func (r *geometryRepository) GetGeometriesByBoundWith(ctx context.Context, bound
|
||||
},
|
||||
ProjectID: convert.UUIDToString(row.ProjectID),
|
||||
IsDeleted: row.IsDeleted,
|
||||
ReplayIDs: convert.ListUUIDToString(row.ReplayIds),
|
||||
CreatedAt: convert.TimeToPtr(row.CreatedAt),
|
||||
UpdatedAt: convert.TimeToPtr(row.UpdatedAt),
|
||||
}
|
||||
@@ -485,6 +490,7 @@ func (r *geometryRepository) getSearchByIDsWithFallback(ctx context.Context, pai
|
||||
BoundWith: convert.UUIDToStringPtr(row.BoundWith),
|
||||
TimeStart: convert.Int4ToPtr(row.TimeStart),
|
||||
TimeEnd: convert.Int4ToPtr(row.TimeEnd),
|
||||
ReplayIDs: convert.ListUUIDToString(row.ReplayIds),
|
||||
}
|
||||
key := cache.Key(item.EntityID, item.GeometryID)
|
||||
dbMap[key] = item
|
||||
@@ -544,6 +550,7 @@ func (r *geometryRepository) SearchByEntityName(ctx context.Context, params sqlc
|
||||
BoundWith: convert.UUIDToStringPtr(row.BoundWith),
|
||||
TimeStart: convert.Int4ToPtr(row.TimeStart),
|
||||
TimeEnd: convert.Int4ToPtr(row.TimeEnd),
|
||||
ReplayIDs: convert.ListUUIDToString(row.ReplayIds),
|
||||
}
|
||||
pair := cache.Key(item.EntityID, item.GeometryID)
|
||||
geometries = append(geometries, item)
|
||||
|
||||
Reference in New Issue
Block a user