Guest User

Untitled

a guest
Feb 21st, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. exports.RemovingApp =
  2. functions.analytics.event('buy_from_shop').onLog(event => {
  3. const bigQuery = bigquery({ projectId: 'littleone-150007' });
  4. bigQuery.query({
  5. query:
  6. Select email from
  7. (SELECT user.value.value.string_value as email,
  8. substr(cast(TIMESTAMP_ADD(TIMESTAMP_MICROS(event.timestamp_micros),
  9. INTERVAL 330 MINUTE) as string),1,10) AS event_date FROM
  10. `in_mylo_pregnancy_baby_app_ANDROID.app_events_*`,
  11. UNNEST(event_dim) AS event,UNNEST(user_dim.user_properties) AS user
  12. WHERE event.name="app_remove"
  13. AND user.key = "email" GROUP BY email, event_date)
  14. useLegacySql: false
  15.  
  16. }).then(function (results) {
  17. var ref = admin.database().ref("appRemoveUsers");
  18.  
  19. var rows = results[0]; //get all fetched table rows
  20. rows.forEach(function(row){ //iterate through each row
  21. ref.push().set({ //write to the database, under the 'DailyAppRemoveDeviceIDs' node
  22. Email:row['email']
  23.  
  24.  
  25. })
  26.  
  27. })
Add Comment
Please, Sign In to add comment