all repos — searchix @ faf67ad3fe2514492c6e0b0cf5361d5b44275a06

Search engine for NixOS, nix-darwin, home-manager and NUR users

feat: improve tracking and display of import runs

Alan Pearce
commit

faf67ad3fe2514492c6e0b0cf5361d5b44275a06

parent

001c5b4f4e6dcf0110504211d3f1298d5e6abc48

1 file changed, 24 insertions(+), 10 deletions(-)

changed files
M internal/index/index_meta.gointernal/index/index_meta.go
@@ -11,17 +11,22 @@ "github.com/Southclaws/fault"
"github.com/Southclaws/fault/fmsg" ) -const CurrentSchemaVersion = 5 +const CurrentSchemaVersion = 6 type SourceMeta struct { - Updated time.Time - Path string - Rev string + ImportedAt time.Time + UpdatedAt time.Time + Path string + Rev string } type data struct { SchemaVersion int - Sources map[string]*SourceMeta + LastImport struct { + StartedAt time.Time + FinishedAt time.Time + } + Sources map[string]*SourceMeta } type Meta struct {
@@ -44,6 +49,7 @@ root: root,
log: log, data: data{ SchemaVersion: CurrentSchemaVersion, + Sources: make(map[string]*SourceMeta), }, }, nil }
@@ -102,17 +108,25 @@ return sourceMeta
} func (i *Meta) SetSourceMeta(source string, meta *SourceMeta) { - if i.Sources == nil { - i.Sources = make(map[string]*SourceMeta) - } i.Sources[source] = meta } +func (i *Meta) LastImported() time.Time { + var last time.Time + for _, sourceMeta := range i.Sources { + if sourceMeta.ImportedAt.After(last) { + last = sourceMeta.ImportedAt + } + } + + return last +} + func (i *Meta) LastUpdated() time.Time { var last time.Time for _, sourceMeta := range i.Sources { - if sourceMeta.Updated.After(last) { - last = sourceMeta.Updated + if sourceMeta.UpdatedAt.After(last) { + last = sourceMeta.UpdatedAt } }