Advertisement
Namokonov

Untitled

Jun 9th, 2021
644
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. function ff() {
  3. Logger.log(getVoo('Н695МТ716'))
  4. }
  5.  
  6.  
  7. function getVoo(plate) {
  8.   var cache = CacheService.getScriptCache();
  9.   var dict = JSON.parse(cache.get(cacheNameVoo));
  10.   if (!dict) { dict = vooToProperty(cache) }
  11.   if (dict.filter(t => t == plate).length) {
  12.     sendMessage(320117024, 'номер найден в базе лицензий.')
  13.   }
  14. }
  15.  
  16. function vooToProperty(cache = CacheService.getScriptCache()) {
  17.   //to_property
  18.   const getVooFromBase = retry(1, get, getIdFromUrl(sourceVuUrl), sourceVuRange).filter(g => g[0]);
  19.   const sheet = SpreadsheetApp.getActive().getSheetByName('аудит');
  20.   const getVooFromActiveSheet = sheet.getRange("F1:L" + sheet.getLastRow()).getValues()
  21.     .filter(g => g[6] == 'лицензия верифицирована').map(g => g[0]);
  22.  
  23.   //unique
  24.   const vooArray = [...new Set(getVooFromBase.concat(getVooFromActiveSheet))];
  25.   // const vooObj = Object.fromEntries(vooArray);
  26.  
  27.   var chunky = ChunkyCache(cache, 1024 * 90);
  28.   chunky.remove(cacheNameVoo);
  29.   console.log('кэш очищен')
  30.   chunky.put(cacheNameVoo, JSON.stringify(vooArray), 1024 * 90);
  31.   console.log('кэш добавлен')
  32.   return vooArray;
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement