generated from broadinstitute/golang-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DDO-3377: Use CreatedAt instead of CommittedAt #398
Open
katiewelch
wants to merge
11
commits into
main
Choose a base branch
from
DDO-3377-change-time
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+14
−17
Open
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3b5878f
remove committedat
katiewelch 1e3e761
add createdat to git_commits_v3
katiewelch d0a2d0b
refactor
katiewelch f4f4ee3
testing
katiewelch 9c9e17d
sql migrations
katiewelch cf6503c
testing
katiewelch de8face
new lines :/
katiewelch bc76dcb
remove commonfields in favor of time.now()
katiewelch e196279
time.since
katiewelch 34886dc
testing
katiewelch d721744
testing
katiewelch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
sherlock/db/migrations/000069_drop_committed_at_column_from_git_commits.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
alter table git_commits | ||
add column if not exists committed_at timestamp with time zone not null; |
2 changes: 2 additions & 0 deletions
2
sherlock/db/migrations/000069_drop_committed_at_column_from_git_commits.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
alter table git_commits | ||
drop column if exists committed_at; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,15 +8,14 @@ import ( | |
"github.com/broadinstitute/sherlock/sherlock/internal/models" | ||
"github.com/gin-gonic/gin" | ||
"net/http" | ||
"time" | ||
) | ||
|
||
type GitCommitV3Upsert struct { | ||
GitRepo string `json:"gitRepo"` | ||
GitCommit string `json:"gitCommit"` | ||
GitBranch string `json:"gitBranch"` | ||
IsMainBranch bool `json:"isMainBranch"` | ||
CommittedAt time.Time `json:"committedAt"` | ||
CommonFields | ||
GitRepo string `json:"gitRepo"` | ||
GitCommit string `json:"gitCommit"` | ||
GitBranch string `json:"gitBranch"` | ||
IsMainBranch bool `json:"isMainBranch"` | ||
} | ||
|
||
// gitCommitsV3Upsert godoc | ||
|
@@ -54,15 +53,14 @@ func gitCommitsV3Upsert(ctx *gin.Context) { | |
var timeSince *uint | ||
|
||
if len(previous) > 0 { | ||
timeSince = utils.PointerTo(uint(body.CommittedAt.Sub(previous[0].CommittedAt).Seconds())) | ||
timeSince = utils.PointerTo(uint(body.CreatedAt.Sub(previous[0].CreatedAt).Seconds())) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Based on my comment above, the body won't have a |
||
} | ||
|
||
var result models.GitCommit | ||
if err = db.Where(&models.GitCommit{GitRepo: body.GitRepo, GitBranch: body.GitBranch, GitCommit: body.GitCommit}). | ||
Attrs(&models.GitCommit{ | ||
IsMainBranch: body.IsMainBranch, | ||
SecSincePrev: timeSince, | ||
CommittedAt: body.CommittedAt, | ||
}).FirstOrCreate(&result).Error; err != nil { | ||
errors.AbortRequest(ctx, err) | ||
return | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: I don't think we actually want to allow upserting the CommonFields, those are typically ready only (the underlying
gorm.Model
is handled by Gorm, so I actually don't know what would happen if you tried to manually set these)