Skip to content

Update ChatName activity timestamp throttle

James Nutt requested to merge jnutt/chatname-timestamp into master

What does this MR do and why?

Updates ChatName activity timestamp throttle

As mentioned in #413368 (comment 1564173408), ChatName records do not have their activity timestamp correctly updated. This is due to an incorrect time comparison. This MR replaces > with .before?, which should yield the correct result, and updates the specs accordingly.

In addition, it removes the global lock on the chat name, as this behaviour duplicates the timezone check.

How to set up and validate locally

  1. Create a chat name for one of your users in the GDK's Rails console:

    user = User.first
    user.chat_names.create(chat_id: 1, team_id: 1)
  2. Set up a Slack command integration in one of your projects and copy the hook URL.

  3. Briefly update ChatName::LAST_USED_AT_INTERVAL to something like 30.seconds.

  4. In your terminal:

    curl --request POST --header "PRIVATE-TOKEN: <your-pat-here>" \
      --url "http://localhost:3000/api/v4/projects/7/integrations/slack_slash_commands/trigger?token=<your-token>&team_id=1&user_id=1"
  5. Verify that ChatName#last_used_at has been updated.

  6. Run the curl command again immediately and verify that the timestamp is unchanged.

  7. Wait for the interval to elapse, re-run the curl command, and verify the new timestamp.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by James Nutt

Merge request reports

Loading