A container registry that uses the AT Protocol for manifest storage and S3 for blob storage.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

try and fix timestamp for historical records

+38
+38
pkg/hold/pds/events.go
··· 140 140 return nil 141 141 } 142 142 143 + // extractCreatedAt attempts to extract createdAt timestamp from various record types 144 + func extractCreatedAt(recordValue any) time.Time { 145 + // Try known types with createdAt fields 146 + switch v := recordValue.(type) { 147 + case map[string]any: 148 + // Generic map fallback (shouldn't happen with lexutil but just in case) 149 + if createdAtStr, ok := v["createdAt"].(string); ok { 150 + if parsed, err := time.Parse(time.RFC3339, createdAtStr); err == nil { 151 + return parsed 152 + } 153 + } 154 + } 155 + 156 + // Try to extract via JSON marshal/unmarshal as last resort 157 + // This works for any struct with a createdAt field 158 + jsonBytes, err := json.Marshal(recordValue) 159 + if err == nil { 160 + var generic map[string]any 161 + if err := json.Unmarshal(jsonBytes, &generic); err == nil { 162 + if createdAtStr, ok := generic["createdAt"].(string); ok { 163 + if parsed, err := time.Parse(time.RFC3339, createdAtStr); err == nil { 164 + return parsed 165 + } 166 + } 167 + } 168 + } 169 + 170 + // Default to current time if no createdAt found 171 + return time.Now() 172 + } 173 + 143 174 // BootstrapFromRepo generates synthetic events from all current records in the repo 144 175 // This is called once when deploying persistent events to an existing repo 145 176 func (b *EventBroadcaster) BootstrapFromRepo(pds *HoldPDS) error { ··· 212 243 collection := strings.Join(parts[:len(parts)-1], "/") 213 244 rkey := parts[len(parts)-1] 214 245 246 + // Extract createdAt timestamp from record if it exists 247 + // Try to extract from known record types with createdAt fields 248 + recordTime := extractCreatedAt(recordValue) 249 + 215 250 // Create synthetic RepoOp 216 251 ops := []RepoOp{ 217 252 { ··· 254 289 b.eventSeq++ 255 290 seq := b.eventSeq 256 291 commitEvent := b.convertToCommitEvent(repoEvent, seq) 292 + 293 + // Override event time with record's original createdAt 294 + commitEvent.Time = recordTime.Format(time.RFC3339) 257 295 258 296 // Persist to database 259 297 if err := b.persistEvent(commitEvent); err != nil {