This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | /* | |
| Delete Events of Incident Events | |
| */ | |
| with results as (select * from | |
| incident_events WHERE | |
| incident_events.incident_id not in ( | |
| select incidents.id from incidents where incidents.id = incident_events.incident_id | |
| )) | |
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | /* | |
| Delete event mentions | |
| */ | |
| with ev as (select * from | |
| incident_events WHERE | |
| incident_events.incident_id IN (select i.id | |
| from incidents i | |
| left join assets on asset_id = assets.id | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | SELECT * | |
| FROM public.messages | |
| WHERE time > (extract(epoch from NOW() - INTERVAL '1 MONTH') * 1000)::bigint | |
| and asset_uuid = 'f52143cb-1cb6-45f7-98b6-4fbe537cd0da' | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | select users.* , ARRAY_AGG(auth.roles.name) as roles | |
| from users | |
| left join auth.permissions on auth.permissions.subject_id = users.id | |
| left join auth.roles on auth.roles.id = auth.permissions.role_id | |
| group by users.id | |
| select users.* , auth.roles.name as role | |
| from users | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | Install the driver by the following commands: | |
| brew tap adrianmihalko/ch340g-ch34g-ch34x-mac-os-x-driver https://github.com/adrianmihalko/ch340g-ch34g-ch34x-mac-os-x-driver | |
| brew cask install wch-ch34x-usb-serial-driver | |
| details https://github.com/adrianmihalko/ch340g-ch34g-ch34x-mac-os-x-driver | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | select * | |
| from "incidents" inner join "assets" on "assets"."id" = "incidents"."asset_id" | |
| inner join "zones" on "zones"."id" = "assets"."zone_id" | |
| inner join "sites" on "sites"."id" = "zones"."site_id" inner join "system_checks" on "system_checks"."site_id" = "sites"."id" | |
| where "incidents"."created_at" >= "system_checks"."from_date" and "incidents"."created_at" <= "system_checks"."to_date" and "system_checks"."id" = '235' and "incidents"."status" | |
| not in ('waiting', 'elapsed') | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | Solution 1 | |
| $ sudo xcode-select --reset | |
| Solution 2 | |
| $ xcode-select --print-path | |
| $ sudo rm -r -f /Library/Developer/CommandLineTools | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | QUEUE_NAME=SEMATICS_QUEUE node playground.js | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | CREATE OR REPLACE FUNCTION calculate_performance_metric(value double precision DEFAULT 0, optimal_low double precision DEFAULT 0, optimal_high double precision DEFAULT 0, alarm_low double precision DEFAULT 0, alarm_high double precision DEFAULT 0) RETURNS device_performance_metric | |
| LANGUAGE plpgsql | |
| STABLE | |
| AS $$ | |
| DECLARE | |
| optimal_below_low_count smallint DEFAULT 0; | |
| optimal_count smallint DEFAULT 0; | |
| optimal_above_high_count smallint DEFAULT 0; | |
| incident_below_low_count smallint DEFAULT 0; | |
| incident_above_high_count smallint DEFAULT 0; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | should match this like string | |
| "_id"\s:\sObjectId\("\w+"\), | |
| /\*\s\d+\s\*/. sjould match /* 13 */ like string |