@@ -188,7 +188,7 @@ func (rb *redisBackend) checkIfExpired(ctx context.Context, id string) (bool, er
188188
189189 score , err := redis .Float64 (redisConn .Do ("ZSCORE" , allTicketsWithTTL , id ))
190190 if errors .Is (err , redis .ErrNil ) {
191- logger .WithError (err ).Errorf ("Ticket id: %s not found" , id )
191+ logger .WithError (err ).Errorf ("checkIfExpired: Ticket id: %s not found" , id )
192192 return true , nil
193193 }
194194 if err != nil {
@@ -452,25 +452,27 @@ func (rb *redisBackend) GetTickets(ctx context.Context, ids []string) ([]*pb.Tic
452452 }
453453 r = append (r , t )
454454
455- if t .Assignment = = nil {
455+ if t .Assignment ! = nil {
456456 // if a ticket is assigned, its given an TTL and automatically de-indexed
457- expiredKey , err := rb .checkIfExpired (ctx , t .Id )
458- if err != nil {
459- err = errors .Wrapf (err , "failed to check ticket expiry, %v" , err )
460- return nil , status .Errorf (codes .Internal , "%v" , err )
461- }
462-
463- if expiredKey {
464- continue
465- }
466-
467- expiry := time .Now ().Add (ticketTTL ).UnixNano ()
468- // update the indexed ticket's ttl. careful this might become slow.
469- err = redisConn .Send ("ZADD" , allTicketsWithTTL , "XX" , "CH" , expiry , t .Id )
470- if err != nil {
471- err = errors .Wrapf (err , "failed to update ttl for ticket id: %s" , t .Id )
472- return nil , status .Errorf (codes .Internal , "%v" , err )
473- }
457+ continue
458+ }
459+
460+ expiredKey , err := rb .checkIfExpired (ctx , t .Id )
461+ if err != nil {
462+ err = errors .Wrapf (err , "failed to check ticket expiry, %v" , err )
463+ return nil , status .Errorf (codes .Internal , "%v" , err )
464+ }
465+
466+ if expiredKey {
467+ continue
468+ }
469+
470+ expiry := time .Now ().Add (ticketTTL ).UnixNano ()
471+ // update the indexed ticket's ttl. careful this might become slow.
472+ err = redisConn .Send ("ZADD" , allTicketsWithTTL , "XX" , "CH" , expiry , t .Id )
473+ if err != nil {
474+ err = errors .Wrapf (err , "failed to update ttl for ticket id: %s" , t .Id )
475+ return nil , status .Errorf (codes .Internal , "%v" , err )
474476 }
475477 }
476478 }
0 commit comments