ExportAll export all event made by the current user to Gitlab
(ctx context.Context, repo *cache.RepoCache, since time.Time)
| 105 | |
| 106 | // ExportAll export all event made by the current user to Gitlab |
| 107 | func (ge *gitlabExporter) ExportAll(ctx context.Context, repo *cache.RepoCache, since time.Time) (<-chan core.ExportResult, error) { |
| 108 | out := make(chan core.ExportResult) |
| 109 | |
| 110 | go func() { |
| 111 | defer close(out) |
| 112 | |
| 113 | allIdentitiesIds := make([]entity.Id, 0, len(ge.identityClient)) |
| 114 | for id := range ge.identityClient { |
| 115 | allIdentitiesIds = append(allIdentitiesIds, id) |
| 116 | } |
| 117 | |
| 118 | allBugsIds := repo.Bugs().AllIds() |
| 119 | |
| 120 | for _, id := range allBugsIds { |
| 121 | select { |
| 122 | case <-ctx.Done(): |
| 123 | return |
| 124 | default: |
| 125 | b, err := repo.Bugs().Resolve(id) |
| 126 | if err != nil { |
| 127 | out <- core.NewExportError(err, id) |
| 128 | return |
| 129 | } |
| 130 | |
| 131 | snapshot := b.Snapshot() |
| 132 | |
| 133 | // ignore issues created before since date |
| 134 | // TODO: compare the Lamport time instead of using the unix time |
| 135 | if snapshot.CreateTime.Before(since) { |
| 136 | out <- core.NewExportNothing(b.Id(), "bug created before the since date") |
| 137 | continue |
| 138 | } |
| 139 | |
| 140 | if snapshot.HasAnyActor(allIdentitiesIds...) { |
| 141 | // try to export the bug and it associated events |
| 142 | ge.exportBug(ctx, b, out) |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | }() |
| 147 | |
| 148 | return out, nil |
| 149 | } |
| 150 | |
| 151 | // exportBug publish bugs and related events |
| 152 | func (ge *gitlabExporter) exportBug(ctx context.Context, b *cache.BugCache, out chan<- core.ExportResult) { |