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
    
  
  
    
  | <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"/> | |
| <title></title> | |
| <link rel="stylesheet" href="https://playground.qlik.com/playground/resources/autogenerated/qlik-styles.css"> | |
| </head> | |
| <body> | |
| <script type="text/javascript" src="https://playground.qlik.com/playground/resources/assets/external/requirejs/require.js"></script> | |
| <script type="text/javascript" src="/node_modules/playground-js-api/dist/playground-js-api.min.js"></script> | 
  
    
      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
    
  
  
    
  | // https://help.qlik.com/en-US/sense-developer/September2018/Subsystems/APIs/Content/Sense_ClientAPIs/CapabilityAPIs/SelectionAPI/qlik-selectionState-interface.htm | |
| // here is a basic example of acquiring and working with the current selection | |
| // state. Here we can get a list of all fields that have selections and what | |
| // values have been selected for each field | |
| var selectionState = app.selectionState() | |
| var listener = function() { | |
| var selections = selectionState.selections | |
| // each item in the selectionState.selections is a field | 
  
    
      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
    
  
  
    
  | const fs = require('fs') | |
| const path = require('path') | |
| require('dotenv').config() | |
| const { dataFile, saveDirectory} = process.env | |
| while(true) { | |
| try { | |
| fs.renameSync(dataFile, path.join(saveDirectory,`${Date.now()}.csv`)) | |
| } catch(e) {} | 
  
    
      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
    
  
  
    
  | version: "2" | |
| services: | |
| engine: | |
| image: qlikcore/engine:12.368.0 | |
| command: -S AcceptEULA=yes -S DocumentDirectory=/docs -S EnableFilePolling=1 | |
| ports: | |
| - "19076:9076" | |
| volumes: | |
| - ./core-docs:/docs | 
  
    
      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
    
  
  
    
  | engine: localhost:19076 | |
| app: Qonnections2019.qvf | |
| script: ./load-script.qvs | |
| connections: | |
| data: | |
| connectionstring: /data | |
| type: folder | 
  
    
      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
    
  
  
    
  | Simulator: | |
| LOAD | |
| * | |
| FROM [lib://data/processed/ski-data.csv] | |
| (txt, utf8, embedded labels, delimiter is ','); | |
| Simulator: | |
| ADD LOAD | |
| [Race ID], | |
| Badge, | 
  
    
      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
    
  
  
    
  | await qixApp.createObject({ | |
| qInfo: { qId: "Badge", qType: "GenericObject" }, | |
| badge: "0", | |
| raceId: "" | |
| }) | |
| await qixApp.doSave() | |
| badgeObject = await qixApp.getObject("Badge") | |
| badgeObject.on("changed", async () => { | |
| checkBadge() | 
  
    
      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
    
  
  
    
  | let results = csvLoad(readDirectory, badgeValue, raceValue) | |
| ... | |
| fs.writeFileSync(unprocessedFile, results.join("\n")) | |
| const reload = await qixApp.doReloadEx({ qPartial: true }) | |
| await qixApp.doSave() | 
  
    
      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
    
  
  
    
  | if (finishedFound) { | |
| ... | |
| const badgePatchProperties = [ | |
| { | |
| qOp: "replace", | |
| qPath: "/badge", | |
| qValue: "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
    
  
  
    
  | const raceId = uuidv4() | |
| const badgePatchProperties = [{ | |
| qOp: "replace", | |
| qPath: "/badge", | |
| qValue: participant.badge | |
| }, | |
| { | |
| qOp: "replace", | |
| qPath: "/raceId", | |
| qValue: `"${raceId}"` |