From 02b8d1383aa80268115856004ffeebb22a996f12 Mon Sep 17 00:00:00 2001 From: tanlang Date: Tue, 28 Feb 2023 06:25:11 +0000 Subject: [PATCH] fix: query sign record by id directly --- storage/sqlite/sign_record.go | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/storage/sqlite/sign_record.go b/storage/sqlite/sign_record.go index 36d94c8..5164f8e 100644 --- a/storage/sqlite/sign_record.go +++ b/storage/sqlite/sign_record.go @@ -61,16 +61,6 @@ func (s *sqliteSignRecord) toSignRecord() *storage.SignRecord { return ret } -func parseId(id string) (signer string, createAt time.Time, err error) { - var nanoSec int64 - _, err = fmt.Sscanf(id, "%d-%s", &nanoSec, &signer) - if err != nil { - return signer, createAt, fmt.Errorf("parse id: %w", err) - } - createAt = time.Unix(0, nanoSec) - return signer, createAt, err -} - type SqliteRecorder struct { db *gorm.DB } @@ -104,11 +94,7 @@ func (s *SqliteRecorder) QueryRecord(params *storage.QueryParams) ([]storage.Sig query := s.db if params.ID != "" { - signer, createAt, err := parseId(params.ID) - if err != nil { - return nil, fmt.Errorf("parse id: %w", err) - } - query = query.Where("signer = ?", signer).Where("created_at <= ?", createAt).Where("created_at >= ?", createAt) + query = query.Where("id = ?", params.ID) } else { if params.Signer != address.Undef { query = query.Where("signer = ?", params.Signer.String())