Ejemplo n.º 1
0
 def get_user_talk_user_ns(self, user_id, lang, start_date, end_date,
                           namespace_type):
     namespace_fn = get_namespace_fn(namespace_type)
     user_df = get_user_edits(lang,
                              user_id,
                              start_date,
                              end_date,
                              wmf_con=self.wmf_con)
     talk_count = user_df['page_namespace'].apply(namespace_fn).sum()
     return talk_count
def add_num_quality_user(user_id, lang, namespace_fn_name, num_quality_revisions_replacement=None):
    db_session = init_session()
    wmf_con = make_wmf_con()
    namespace_fn = get_namespace_fn(namespace_fn_name)
    quality_revisions = num_quality_revisions if num_quality_revisions_replacement is None else num_quality_revisions_replacement
    num_quality = quality_revisions(user_id=user_id, lang=lang, wmf_con=wmf_con,
                                        namespace_fn=namespace_fn)
    user_rec = db_session.query(candidates).filter(candidates.lang == lang).filter(
        candidates.user_id == user_id).first()
    user_rec.user_editcount_quality = num_quality
    db_session.add(user_rec)
    db_session.commit()
    def __init__(self,
                 config_file,
                 get_active_users_replacement=None,
                 db_session_replacement=None):
        """groups needing edits and size N edits to be included which k edits to be displayed
        """
        config = yaml.safe_load(
            open(
                os.path.join(
                    Path(__file__).parent.parent, 'config', config_file), 'r'))
        self.config = config
        self.langs = config['langs']
        self.min_edit_count = config['min_edit_count']
        self.wmf_con = make_wmf_con()
        self.db_session = init_session(
        ) if not db_session_replacement else db_session_replacement
        self.experiment_start_date = config['experiment_start_date']
        self.onboarding_earliest_active_date = self.experiment_start_date - timedelta(
            days=config['observation_back_days'])
        self.onboarding_latest_active_date = datetime.utcnow()
        self.populations = defaultdict(dict)
        self.namespace_fn = get_namespace_fn(config['namespace_fn'])
        self.get_active_users_replacement = get_active_users_replacement
        self.get_active_users = get_active_users if not get_active_users_replacement else get_active_users_replacement

        if 'max_onboarders_to_check' in self.config.keys():
            self.max_onboarders_to_check = self.config[
                'max_onboarders_to_check']
        else:
            self.max_onboarders_to_check = None

        self.users_in_thanker_experiment = {
            "ar": [],
            "de": [],
            "fa": [],
            "pl": [],
            "en": []
        }

        self.q = Queue(name='onboarder_thankee', connection=Redis())
        self.failed_q = Queue(name='failed', connection=Redis())
Ejemplo n.º 4
0
 def add_project_talk(self, df, lang):
     return self.create_talk_df(df,
                                namespace_fn=get_namespace_fn('project'),
                                lang=lang,
                                col_label='project_talk_84_pre_treatment')