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

Commit 340fa1f

Browse files
Add datalake file path to cache (#51)
* add datalake file path to cache Signed-off-by: Ayman <[email protected]> * clean up Signed-off-by: Ayman <[email protected]> Signed-off-by: Ayman <[email protected]> Co-authored-by: Ayman <[email protected]>
1 parent 4ae8882 commit 340fa1f

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

cmd/git/git.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ var (
515515

516516
// Publisher - for streaming data to Kinesis
517517
type Publisher interface {
518-
PushEvents(action, source, eventType, subEventType, env string, data []interface{}) error
518+
PushEvents(action, source, eventType, subEventType, env string, data []interface{}) (string, error)
519519
}
520520

521521
// RawPLS - programming language summary (all fields as strings)
@@ -1778,19 +1778,28 @@ func (j *DSGit) GitEnrichItems(ctx *shared.Ctx, thrN int, items []interface{}, d
17781778
continue
17791779
}
17801780
vals = append(vals, map[string]interface{}{
1781-
"id": d.Payload.ID,
1782-
"data": b,
1781+
"id": d.Payload.ID,
1782+
"data": map[string]interface{}{
1783+
"content": b,
1784+
},
17831785
})
17841786
}
17851787
}
1786-
err = j.cacheProvider.Create(j.endpoint, vals)
1788+
path := ""
17871789
if len(formattedData) > 0 {
1788-
err = j.Publisher.PushEvents(CommitCreated, "insights", GitDataSource, "commits", os.Getenv("STAGE"), formattedData)
1790+
path, err = j.Publisher.PushEvents(CommitCreated, "insights", GitDataSource, "commits", os.Getenv("STAGE"), formattedData)
17891791
if err != nil {
17901792
j.log.WithFields(logrus.Fields{"operation": "GitEnrichItems"}).Errorf("Error: %+v", err)
17911793
return
17921794
}
17931795
}
1796+
if len(vals) > 0 {
1797+
for i, o := range vals {
1798+
o["data"].(map[string]interface{})["path"] = path
1799+
vals[i] = o
1800+
}
1801+
err = j.cacheProvider.Create(j.endpoint, vals)
1802+
}
17941803
} else {
17951804
var jsonBytes []byte
17961805
jsonBytes, err = jsoniter.Marshal(data)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.17
44

55
require (
66
github.com/LF-Engineering/insights-datasource-shared v1.5.13-0.20220823221255-792e9bbc15c7
7-
github.com/LF-Engineering/lfx-event-schema v0.1.30
7+
github.com/LF-Engineering/lfx-event-schema v0.1.33
88
github.com/aws/aws-lambda-go v1.27.1
99
github.com/aws/aws-sdk-go v1.42.25
1010
github.com/json-iterator/go v1.1.11

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
22
github.com/LF-Engineering/insights-datasource-shared v1.5.13-0.20220823221255-792e9bbc15c7 h1:/hH1GY0sZ537pch+ttGuaAfTtXHmeKwQKj1FyN2TxEM=
33
github.com/LF-Engineering/insights-datasource-shared v1.5.13-0.20220823221255-792e9bbc15c7/go.mod h1:ZQCRAJNyizhBemQDSjqm14G2MPkOJbRzCPfjwFhYKy4=
44
github.com/LF-Engineering/lfx-event-schema v0.1.14/go.mod h1:CfFIZ4mwzo88umf5+KxDQEzqlVkPG7Vx8eLK2oDfWIs=
5-
github.com/LF-Engineering/lfx-event-schema v0.1.30 h1:s20N1/m0lzLDdHhFjho0hWn/os2aY0ewtgxsiJpS7Hs=
6-
github.com/LF-Engineering/lfx-event-schema v0.1.30/go.mod h1:CfFIZ4mwzo88umf5+KxDQEzqlVkPG7Vx8eLK2oDfWIs=
5+
github.com/LF-Engineering/lfx-event-schema v0.1.33 h1:5Yk20tPkPbyOKEckcEF87qEQtl1H8l6TyA9wjKi+cl0=
6+
github.com/LF-Engineering/lfx-event-schema v0.1.33/go.mod h1:CfFIZ4mwzo88umf5+KxDQEzqlVkPG7Vx8eLK2oDfWIs=
77
github.com/alecthomas/jsonschema v0.0.0-20210920000243-787cd8204a0d/go.mod h1:/n6+1/DWPltRLWL/VKyUxg6tzsl5kHUCcraimt4vr60=
88
github.com/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHSxpiH9JdtuBj0=
99
github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY=

0 commit comments

Comments
 (0)