Skip to content

insights: add background process to freeze insights based on license check

Created by: CristinaBirkel

Add a new boolean column to insight_view called is_frozen. Defaults to FALSE.

Add a new background process that wakes up every N minutes and does the following:

  1. Checks for the code insights license.
  2. If they have a license:
    • Run a SQL query to ensure is_frozen is false for all insight_views. (Alternately, we could check to see if anything is frozen, and do nothing if it's already in the correct state.)
  3. If they do NOT have a license:
    • First check to see if there are > 2 global insights that are unfrozen, or any non-global insights that are unfrozen. If not, do nothing.
      • The reason for this check: if they delete one (or both) of their default unfrozen insights, they may create more. We don't want to run a generic "freeze" operation that would potentially unfreeze earlier created insights and freeze the newer ones.
    • If there are > 2 unfrozen insights:
      • Freeze all insights EXCEPT the first 2 (by id since we don't store a creation date) global insights.
      • (If there are no global insights, freeze everything.)

In the future we may want to do more work to purge series data, stop snapshots, etc., but for now we'll leave all of the data as-is, (except for marking these insights as frozen.)