2018-08-06 21:31:20 +03:00
|
|
|
package bug
|
|
|
|
|
|
|
|
import (
|
2020-09-16 17:22:02 +03:00
|
|
|
"github.com/MichaelMure/git-bug/identity"
|
2018-08-06 21:31:20 +03:00
|
|
|
"github.com/MichaelMure/git-bug/repository"
|
|
|
|
)
|
|
|
|
|
2020-06-23 19:02:54 +03:00
|
|
|
// ClockLoader is the repository.ClockLoader for the Bug entity
|
|
|
|
var ClockLoader = repository.ClockLoader{
|
|
|
|
Clocks: []string{creationClockName, editClockName},
|
|
|
|
Witnesser: func(repo repository.ClockedRepo) error {
|
2020-09-16 17:22:02 +03:00
|
|
|
// We don't care about the actual identity so an IdentityStub will do
|
|
|
|
resolver := identity.NewStubResolver()
|
|
|
|
for b := range ReadAllLocalWithResolver(repo, resolver) {
|
2020-06-23 19:02:54 +03:00
|
|
|
if b.Err != nil {
|
|
|
|
return b.Err
|
|
|
|
}
|
2018-08-06 21:31:20 +03:00
|
|
|
|
2020-06-23 19:02:54 +03:00
|
|
|
createClock, err := repo.GetOrCreateClock(creationClockName)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
err = createClock.Witness(b.Bug.createTime)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-09-13 13:43:47 +03:00
|
|
|
|
2020-06-23 19:02:54 +03:00
|
|
|
editClock, err := repo.GetOrCreateClock(editClockName)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
err = editClock.Witness(b.Bug.editTime)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-09-13 13:43:47 +03:00
|
|
|
}
|
2018-08-06 21:31:20 +03:00
|
|
|
|
2020-06-23 19:02:54 +03:00
|
|
|
return nil
|
|
|
|
},
|
2018-08-06 21:31:20 +03:00
|
|
|
}
|