Ejemplo n.º 1
0
    def __init__(self,year,activation=5,overall=False):

        self.year = year
        '''The year the cohort started.
        '''
        self.activation = activation
        '''Minimum number of edits per month to be included in the cohort
        '''
        self.overall = overall

        ts,ts_i = utils.create_time_stamps_month(fromym='%s01'%self.year,toym='201012')
        self.time_stamps = ts 
        self.time_stamps_index = ts_i
        '''Only take time_stamps starting with self.year
        '''

        self.cohorts = [self.year,'others']
        '''Cohort definition
        '''
        self.cohort_labels = ['%s cohort'% i for i in self.cohorts]
        '''Cohort labels
        '''

        if self.overall:
            self.sqlQuery = "SELECT *  FROM fabian WHERE user_id IN (SELECT user_id FROM fabian WHERE first_edit_year=%s GROUP BY user_id HAVING SUM(add_edits)>%s);"%(self.year,self.activation)
        else:
            self.sqlQuery = 'SELECT *  FROM fabian WHERE add_edits > %s AND first_edit_year=%s'%(self.activation,self.year)

        Cohort.__init__(self)
Ejemplo n.º 2
0
def readConfig(configfile):
    '''
	Reads the configuration from `ConfigParser` instance into the runtime settings.

	:arg configfile: A file that can be read by a `ConfigParser` instance
	'''

    global language, filterbots, time_stamps, time_stamps_index, botfile, basedirectory, datadirectory, userlistdirectory, reportdirectory, wikipridedirectory, sqlhost, sqlwikidb, sqluserdb, sqlconfigfile, sqldroptables

    import os
    import ConfigParser

    config = ConfigParser.ConfigParser()
    config.read(configfile)

    # general settings
    language = config.get('General', 'language')
    if len(language) != 2:
        raise Exception('Language code should be two characters (%s)' %
                        language)

    filterbots = config.get('General', 'filterbots')

    startYM = config.get('General', 'startYM')
    endYM = config.get('General', 'endYM')
    (time_stamps,
     time_stamps_index) = utils.create_time_stamps_month(fromym=startYM,
                                                         toym=endYM)

    # directories
    basedirectory = os.path.expanduser(
        config.get('Directories', 'basedirectory'))
    datadirectory = os.path.expanduser(
        config.get('Directories', 'datadirectory'))
    userlistdirectory = os.path.expanduser(
        config.get('Directories', 'userlistdirectory'))
    reportdirectory = os.path.expanduser(
        config.get('Directories', 'reportdirectory'))
    wikipridedirectory = os.path.expanduser(
        config.get('Directories', 'wikipridedirectory'))

    # if not os.path.isdir(basedirectory):
    # 	import errno
    # 	try:
    # 	    os.makedirs(p)
    # 	except OSError as exc: # Python >2.5
    # 	    if exc.errno == errno.EEXIST:
    # 	        pass
    # 	    else: raise

    # sql
    sqlhost = config.get('MySQL', 'sqlhost')
    sqlwikidb = config.get('MySQL', 'sqlwikidb')
    sqluserdb = config.get('MySQL', 'sqluserdb')
    sqlconfigfile = config.get('MySQL', 'sqlconfigfile')
    sqldroptables = config.getboolean('MySQL', 'sqldroptables')

    sqlconfigfile = os.path.expanduser(sqlconfigfile)
    if not os.path.isfile(sqlconfigfile):
        logger.warning("%s sql config file not found" % sqlconfigfile)
Ejemplo n.º 3
0
    def __init__(self):

        ts_month,ts_month_index = utils.create_time_stamps_month()

        self.cohorts = [int(i) for i in range(0,len(ts_month))]        
        '''Cohort definition
        '''
        self.cohort_labels = ['%s days old'% i for i in self.cohorts]
        '''Cohort labels
        '''                        
        Age.__init__(self)
Ejemplo n.º 4
0
    def __init__(self):

        ts_month, ts_month_index = utils.create_time_stamps_month()

        self.cohorts = [int(i) for i in range(0, len(ts_month))]
        '''Cohort definition
        '''
        self.cohort_labels = ['%s days old' % i for i in self.cohorts]
        '''Cohort labels
        '''
        Age.__init__(self)
Ejemplo n.º 5
0
def mobile_pageviews_target(min_ts, max_ts):
    return
    # input files
    metricfile = "../datafiles/rc_page_requests_mobile.csv"
    targetfile = "../misc/targets/mobile_target.csv"

    # time range
    tss, tss_i = utils.create_time_stamps_month(fromym=min_ts, toym=max_ts)

    target = extractData(targetfile, "\t", "MMM-YY", [("Target", 3)])
    actual = extractData(metricfile, ",", "YYYY/MM/DD", [("Total", 1)])
Ejemplo n.º 6
0
def readConfig(configfile):
	'''
	Reads the configuration from `ConfigParser` instance into the runtime settings.

	:arg configfile: A file that can be read by a `ConfigParser` instance
	'''

	global language,filterbots,time_stamps,time_stamps_index,botfile,basedirectory,datadirectory,userlistdirectory,reportdirectory,wikipridedirectory,sqlhost,sqlwikidb,sqluserdb,sqlconfigfile,sqldroptables

	import os
	import ConfigParser

	config = ConfigParser.ConfigParser()
	config.read(configfile)

	# general settings
	language = config.get('General','language') 
	if len(language) != 2:
		raise Exception('Language code should be two characters (%s)'%language)

	filterbots = config.get('General','filterbots')	
	
	startYM = config.get('General','startYM') 
	endYM = config.get('General','endYM') 
	(time_stamps,time_stamps_index) = utils.create_time_stamps_month(fromym=startYM,toym=endYM)
	
	# directories	
	basedirectory = os.path.expanduser(config.get('Directories','basedirectory'))
	datadirectory = os.path.expanduser(config.get('Directories','datadirectory'))
	userlistdirectory = os.path.expanduser(config.get('Directories','userlistdirectory'))
	reportdirectory = os.path.expanduser(config.get('Directories','reportdirectory'))
	wikipridedirectory = os.path.expanduser(config.get('Directories','wikipridedirectory'))

	# if not os.path.isdir(basedirectory):
	# 	import errno
	# 	try:
	# 	    os.makedirs(p)
	# 	except OSError as exc: # Python >2.5
	# 	    if exc.errno == errno.EEXIST:
	# 	        pass
	# 	    else: raise

	# sql
	sqlhost = config.get('MySQL','sqlhost')
	sqlwikidb = config.get('MySQL','sqlwikidb')
	sqluserdb = config.get('MySQL','sqluserdb')
	sqlconfigfile = config.get('MySQL','sqlconfigfile')	
	sqldroptables = config.getboolean('MySQL','sqldroptables')	

	sqlconfigfile = os.path.expanduser(sqlconfigfile)
	if not os.path.isfile(sqlconfigfile):
		logger.warning("%s sql config file not found"%sqlconfigfile)
Ejemplo n.º 7
0
def active_editors_target(min_ts, max_ts):
    return
    # input files

    metricfile = os.path.join(old_to_new.output_folder, "rc_active_editors_count.csv")
    # metricfile = '../data/datafiles/rc/rc_active_editors_count.csv'
    targetfile = "../misc/targets/editor_target.csv"

    # time range
    tss, tss_i = utils.create_time_stamps_month(fromym=min_ts, toym=max_ts)

    target = extractData(targetfile, "\t", "MMM-YY", [("Projected", 1), ("Target", 2)])
    actual = extractData(metricfile, ",", "YYYY/MM/DD", [("Total", 1)])
Ejemplo n.º 8
0
    def __init__(self,activation=5):


        self.activation =  activation

        self.NS = ( '4', '5' )

        ts,ts_i = utils.create_time_stamps_month(fromym='200401',toym='201012')
        self.time_stamps = ts 
        self.time_stamps_index = ts_i
        '''Only take time_stamps starting with self.year
        '''

        self.cohorts = range(2004,2011)
        '''Cohort definition
        '''
        self.cohort_labels = ['%s cohort'% i for i in self.cohorts]
        '''Cohort labels
        '''

        # self.sqlQuery = 'SELECT * FROM fabian WHERE namespace IN (4,5) AND add_edits > %s AND first_edit_year in (%s)'%(self.activation,','.join([str(c) for c in self.cohorts]))


        Cohort.__init__(self)
Ejemplo n.º 9
0
def setTimeStamps(startYM, endYM):
    global time_stamps, time_stamps_index
    (time_stamps,
     time_stamps_index) = utils.create_time_stamps_month(fromym=startYM,
                                                         toym=endYM)
Ejemplo n.º 10
0
def setTimeStamps(startYM,endYM):
	global time_stamps,time_stamps_index
	(time_stamps,time_stamps_index) = utils.create_time_stamps_month(fromym=startYM,toym=endYM)