Advertisement
Guest User

Untitled

a guest
Mar 1st, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. const injector = angular.element(document.body).injector();
  2. const storageService = injector.get('storageService');
  3. const http = injector.get('$http');
  4.  
  5. (async () => {
  6. const file = await http.get('https://portalvhdsnlbdnh2b4h8cq.blob.core.windows.net/applications/autoinvest-data-production_data.json');
  7. //const file = await http.get('https://portalvhdsnlbdnh2b4h8cq.blob.core.windows.net/applications/autoinvest-data-staging-export.json');
  8. const data = file.data;
  9. console.log(data);
  10.  
  11. const userId = window.profile.userId;
  12. const user = data.users[userId];
  13.  
  14. const accounts = user.accounts;
  15. if (!accounts) {
  16. alert('no account');
  17. return;
  18. }
  19.  
  20. for (const account of Object.values(accounts)) {
  21. if (account.type === 'ig') {
  22. account.username = 'dummy';
  23. account.password = 'dummy';
  24. }
  25. storageService.insertAccount(account);
  26. console.log('account', account);
  27. }
  28.  
  29. const linkings = user.linkings;
  30. const logs = data.logs[userId];
  31.  
  32. for (const linking of linkings) {
  33.  
  34. const lgs = Object.values(logs);
  35. //debugger;
  36. const logObj = lgs.find(log => log.linking._id === linking.id);
  37. if (logObj) {
  38. const lk = logObj.linking;
  39. console.log('linking', lk);
  40. storageService.linkStrategyAndAccount(lk.strategy, lk.account, lk.config, lk.active);
  41. } else {
  42. alert('No log for this linking');
  43. }
  44. }
  45. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement