Skip to content

Instantly share code, notes, and snippets.

View saptarshiguha's full-sized avatar

Saptarshi Guha saptarshiguha

View GitHub Profile
## For Session Hours Per Day Per Profile
### For profiles on 56
with a as (
select client_id, submission_date_s3, sum(subsession_length)/3600 as hours
from main_summary
where app_name='Firefox'
and substring(app_version,1,2)='56'
and submission_date_s3 >= '2017-09-25'
## For Session Hours Per Day Per Profile
### For profiles on 56
with a as (
select client_id, submission_date_s3, sum(subsession_length)/3600 as hours
from main_summary
where app_name='Firefox'
and substring(app_version,1,2)='56'
and submission_date_s3 >= '2017-09-25'
```{r eval=FALSE}
getADIAllAndV <- function(sdate,edate, version,col1)
{
ff <- data.table(d$q(i <- sprintf(
"select
bl_date as date,
sum(tot_requests_on_date) as %s
from
### Data Extraction
#### Python Extraction Code
To keep it analysis for existing users comparable to the new profile analysis,
if a profile
- updated to Firefox Beta 56 between August 8th, 2017 and 14 days thereafter,
- they were on some version before 56
---
title: "R Notebook"
output:
html_document:
highlight: pygments
---
```{r}
```{python}
from pyspark.sql import SparkSession
import subprocess
import json
import datetime
import pandas as pd
spark = SparkSession.builder.getOrCreate()
sys.path.append("/home/hadoop/")
```{r}
## Get the JSON file of releases
library(rjson)
library(data.table)
library(infuser)
download.file('https://product-details.mozilla.org/1.0/firefox_history_major_releases.json',dest='/tmp/x.json')
releases <- local({
x <- fromJSON(file='/tmp/x.json')
data.table(version=names(x), date=as.Date(unlist(x)))
})[date>='2016-07-01',]
```{r}
## Get the JSON file of releases
library(rjson)
library(data.table)
library(infuser)
download.file('https://product-details.mozilla.org/1.0/firefox_history_major_releases.json',dest='/tmp/x.json')
releases <- local({
x <- fromJSON(file='/tmp/x.json')
data.table(version=names(x), date=as.Date(unlist(x)))
})[date>='2016-07-01',]
---
title: Flash Engagement for **Existing Profiles**
<br/>( Click to Activate )
author: Saptarshi Guha <[email protected]>
date: "`r format(Sys.time(), '%B %d, %Y')`"
output:
html_document:
mathjax: default
self_contained: true
theme: readable
library(httr)
library(infuser)
## See https://docs.databricks.com/api/1.2/index.html#execution-context
ctxMake <- function(instance,clusterId,user,password){
url <- infuse("https://{{instance}}.cloud.databricks.com/api/1.2/contexts/create",instance=instance)
pyctx<-POST(url,body=list(language='python', clusterId=clusterId)
,encode='form'
,authenticate(user,password))