Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #20 from LF-Engineering/handle-empty-sync
Browse files Browse the repository at this point in the history
Handle empty sync and bot identity
  • Loading branch information
khalifapro authored Nov 15, 2022
2 parents 284d5cb + e3cf673 commit 0a2b71c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
14 changes: 11 additions & 3 deletions cmd/confluence/confluence.go
Original file line number Diff line number Diff line change
Expand Up @@ -764,9 +764,11 @@ func (j *DSConfluence) Sync(ctx *shared.Ctx) (err error) {
// NOTE: Non-generic ends here
gMaxUpdatedAtMtx.Lock()
defer gMaxUpdatedAtMtx.Unlock()
err = j.cacheProvider.SetLastSync(j.endpoint, gMaxUpdatedAt)
if err != nil {
j.log.WithFields(logrus.Fields{"operation": "Sync"}).Infof("unable to set last sync date to cache.error: %v", err)
if !gMaxUpdatedAt.IsZero() {
err = j.cacheProvider.SetLastSync(j.endpoint, gMaxUpdatedAt)
if err != nil {
j.log.WithFields(logrus.Fields{"operation": "Sync"}).Infof("unable to set last sync date to cache.error: %v", err)
}
}
return
}
Expand Down Expand Up @@ -1178,6 +1180,7 @@ func (j *DSConfluence) GetModelData(ctx *shared.Ctx, docs []interface{}) (data m
j.log.WithFields(logrus.Fields{"operation": "GetModelData"}).Errorf("GenerateIdentity(%s,%s,%s,%s): %+v for %+v", source, email, name, username, err, doc)
return
}
isBotIdentity := shared.IsBotIdentity(name, username, email, ConfluenceDataSource, os.Getenv("BOT_NAME_REGEX"), os.Getenv("BOT_USERNAME_REGEX"), os.Getenv("BOT_EMAIL_REGEX"))
contributors := []insights.Contributor{
{
Role: insights.AuthorRole,
Expand All @@ -1190,6 +1193,7 @@ func (j *DSConfluence) GetModelData(ctx *shared.Ctx, docs []interface{}) (data m
Username: username,
Source: ConfluenceDataSource,
Avatar: avatar,
IsBot: isBotIdentity,
},
},
}
Expand All @@ -1206,6 +1210,7 @@ func (j *DSConfluence) GetModelData(ctx *shared.Ctx, docs []interface{}) (data m
j.log.WithFields(logrus.Fields{"operation": "GetModelData"}).Errorf("GenerateIdentity(%s,%s,%s,%s): %+v for %+v", source, email, name, username, err, doc)
return
}
isBotIdentity2 := shared.IsBotIdentity(name, username, email, ConfluenceDataSource, os.Getenv("BOT_NAME_REGEX"), os.Getenv("BOT_USERNAME_REGEX"), os.Getenv("BOT_EMAIL_REGEX"))
contributor := insights.Contributor{
Role: insights.AuthorRole,
Weight: 1.0,
Expand All @@ -1217,6 +1222,7 @@ func (j *DSConfluence) GetModelData(ctx *shared.Ctx, docs []interface{}) (data m
Username: username,
Source: ConfluenceDataSource,
Avatar: avatar,
IsBot: isBotIdentity2,
},
}
contributors = append(contributors, contributor)
Expand All @@ -1235,6 +1241,7 @@ func (j *DSConfluence) GetModelData(ctx *shared.Ctx, docs []interface{}) (data m
j.log.WithFields(logrus.Fields{"operation": "GetModelData"}).Errorf("GenerateIdentity(%s,%s,%s,%s): %+v for %+v", source, email, name, username, err, doc)
return
}
isBotIdentity2 := shared.IsBotIdentity(name, username, email, ConfluenceDataSource, os.Getenv("BOT_NAME_REGEX"), os.Getenv("BOT_USERNAME_REGEX"), os.Getenv("BOT_EMAIL_REGEX"))
contributor := insights.Contributor{
Role: insights.AuthorRole,
Weight: 1.0,
Expand All @@ -1246,6 +1253,7 @@ func (j *DSConfluence) GetModelData(ctx *shared.Ctx, docs []interface{}) (data m
Username: username,
Source: ConfluenceDataSource,
Avatar: avatar,
IsBot: isBotIdentity2,
},
}
contributors = append(contributors, contributor)
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/LF-Engineering/insights-connector-confluence
go 1.17

require (
github.com/LF-Engineering/insights-datasource-shared v1.5.13-0.20220819120005-3a892d388ffb
github.com/LF-Engineering/lfx-event-schema v0.1.20-0.20220510142557-956ba192fade
github.com/LF-Engineering/insights-datasource-shared v1.5.20
github.com/LF-Engineering/lfx-event-schema v0.1.29
github.com/aws/aws-sdk-go v1.43.3
github.com/json-iterator/go v1.1.12
github.com/sirupsen/logrus v1.8.1
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
github.com/LF-Engineering/insights-datasource-shared v1.5.13-0.20220819120005-3a892d388ffb h1:dgtYhCimKfw0SYrbNT0CSpcgo2KdcilqBr5Q1AtSHgs=
github.com/LF-Engineering/insights-datasource-shared v1.5.13-0.20220819120005-3a892d388ffb/go.mod h1:ZQCRAJNyizhBemQDSjqm14G2MPkOJbRzCPfjwFhYKy4=
github.com/LF-Engineering/insights-datasource-shared v1.5.20 h1:qYH3NDoa2Y/35KgWiNauISddebkQEzGYUubK3idb8AQ=
github.com/LF-Engineering/insights-datasource-shared v1.5.20/go.mod h1:9DmFQbC8nnm1C7k+/tDo3Rmqzzx7AzmhPBlFouXaBZ8=
github.com/LF-Engineering/lfx-event-schema v0.1.14/go.mod h1:CfFIZ4mwzo88umf5+KxDQEzqlVkPG7Vx8eLK2oDfWIs=
github.com/LF-Engineering/lfx-event-schema v0.1.20-0.20220510142557-956ba192fade h1:YTBk0uQnUVrfEFcyHaR2hzVXDh6ebmeliV0f/O/jj8c=
github.com/LF-Engineering/lfx-event-schema v0.1.20-0.20220510142557-956ba192fade/go.mod h1:CfFIZ4mwzo88umf5+KxDQEzqlVkPG7Vx8eLK2oDfWIs=
github.com/LF-Engineering/lfx-event-schema v0.1.29 h1:3+0gKTzaeEqXBKAia+eLF3QIlxdrTlmMVRCxSdSbXqQ=
github.com/LF-Engineering/lfx-event-schema v0.1.29/go.mod h1:CfFIZ4mwzo88umf5+KxDQEzqlVkPG7Vx8eLK2oDfWIs=
github.com/alecthomas/jsonschema v0.0.0-20210920000243-787cd8204a0d/go.mod h1:/n6+1/DWPltRLWL/VKyUxg6tzsl5kHUCcraimt4vr60=
github.com/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHSxpiH9JdtuBj0=
github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY=
Expand Down

0 comments on commit 0a2b71c

Please sign in to comment.