77import org .springframework .beans .factory .annotation .Autowired ;
88import org .springframework .stereotype .Service ;
99
10+ import java .sql .Timestamp ;
11+
1012@ Service
1113public class UserRepositoryService {
1214
@@ -15,7 +17,10 @@ public class UserRepositoryService {
1517 @ Autowired
1618 private UserRepository userRepository ;
1719
20+ Timestamp timestamp = new Timestamp (System .currentTimeMillis ());
21+
1822 public Profile update (Profile updateEntry ) {
23+ long start = System .currentTimeMillis ();
1924 Preconditions .checkNotNull (updateEntry , "User profile cannot be null" );
2025
2126 LOGGER .info ("Updating user profile for user=%s" , updateEntry .getId ());
@@ -34,13 +39,24 @@ public Profile update(Profile updateEntry) {
3439 existingUser .setRating (updateEntry .getRating () == null ? existingUser .getRating () : updateEntry .getRating ());
3540 existingUser .setRating (updateEntry .getRanking () == null ? existingUser .getRanking () : updateEntry .getRanking ());
3641
37- return save (existingUser );
42+ Profile userProfile = save (existingUser );
43+ long end = System .currentTimeMillis ();
44+ long timeElapsed = end - start ;
45+
46+ LOGGER .info ("Update method called: on {} and response time in ms: {}" , timestamp , timeElapsed );
47+ return userProfile ;
3848 }
3949
4050 public Profile save (Profile newProfile ) {
4151 Preconditions .checkNotNull (newProfile , "User profile cannot be null" );
42- LOGGER .info ("Saving new user profile for user=%s" , newProfile .getId ());
43- return userRepository .save (newProfile );
52+
53+ long start = System .currentTimeMillis ();
54+ Profile userProfile = userRepository .save (newProfile );
55+ long end = System .currentTimeMillis ();
56+ long timeElapsed = end - start ;
57+
58+ LOGGER .info ("Save method called: on {} and response time in ms: {}" , timestamp , timeElapsed );
59+ return userProfile ;
4460 }
4561
4662 private Profile findOne (String Id ) {
0 commit comments