Skip to content

Fix/challenge timestamp issue #784

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

Merged
merged 12 commits into from
Aug 7, 2022
Merged

Fix/challenge timestamp issue #784

merged 12 commits into from
Aug 7, 2022

Conversation

lpoli
Copy link
Contributor

@lpoli lpoli commented Aug 5, 2022

Fixes

This PR removes ambiguity in CreatedAt field.

Tests

Tasks to complete before merging PR:

  • Ensure system tests are passing. If not Run them manually to check for any regressions 📋
  • Do any new system tests need added to test this change? do any existing system tests need updated? If so create a PR at 0chain/system_test
  • Merge your system tests PR to master AFTER merging this PR

Associated PRs (Link as appropriate):

  • 0chain:
  • gosdk:
  • system_test:
  • zboxcli:
  • zwalletcli:
  • Other: ...

@lpoli lpoli requested a review from ssardana08 August 5, 2022 14:34
@codecov-commenter
Copy link

codecov-commenter commented Aug 5, 2022

Codecov Report

Merging #784 (b07d44a) into staging (9c004bc) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff            @@
##           staging     #784   +/-   ##
========================================
  Coverage    24.64%   24.64%           
========================================
  Files           77       77           
  Lines         7871     7871           
========================================
  Hits          1940     1940           
  Misses        5663     5663           
  Partials       268      268           
Flag Coverage Δ
Unit-Tests 24.64% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Help us with your feedback. Take ten seconds to tell us how you rate us.

@lpoli lpoli requested a review from ssardana08 August 6, 2022 01:02

if err := db.Transaction(func(tx *gorm.DB) error {
return c.SaveWith(tx)
}); err != nil {
logging.Logger.Error("[challenge]add: ",
zap.String("challenge_id", c.ChallengeID),
zap.Time("created", c.CreatedAt),
zap.Time("created", common.ToTime(c.CreatedAt)),
Copy link
Contributor

@peterlimg peterlimg Aug 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd better call common.ToTime() one time, and use the result to avoid redundant time conversions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

if time.Since(common.ToTime(cr.CreatedAt)) > config.Configuration.ChallengeCompletionTime {
cr.Status = Cancelled
cr.StatusMessage = "challenge completion time expired"
cr.UpdatedAt = time.Now().UTC()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to call cr.Save() to update the changes to db.

@lpoli lpoli requested a review from peterlimg August 7, 2022 01:39
Copy link
Contributor

@peterlimg peterlimg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@lpoli lpoli dismissed ssardana08’s stale review August 7, 2022 02:54

Requested changes are made

@lpoli lpoli merged commit f2014a7 into staging Aug 7, 2022
@lpoli lpoli deleted the fix/challenge-timestamp-issue branch August 7, 2022 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants