Esempio n. 1
0
    def _set_enrollment(self,
                        experiment,
                        alternative,
                        enrollment_date=None,
                        last_seen=None):
        enrollments = self.session.get('experiments_enrollments', {})
        enrollments[experiment.name] = (alternative, None,
                                        timestamp_from_datetime(enrollment_date
                                                                or now()),
                                        timestamp_from_datetime(last_seen))
        self.session['experiments_enrollments'] = enrollments
        if self._is_verified_human():
            self.experiment_counter.increment_participant_count(
                experiment, alternative, self._participant_identifier())
        else:
            logger.info(
                json.dumps({
                    'type': 'participant_unconfirmed',
                    'experiment': experiment.name,
                    'alternative': alternative,
                    'participant': self._participant_identifier()
                }))

        user_enrolled.send(self,
                           experiment=experiment.name,
                           alternative=alternative,
                           user=None,
                           session=self.session)
Esempio n. 2
0
 def _set_last_seen(self, experiment, last_seen):
     enrollments = self.session.get('experiments_enrollments', {})
     alternative, unused, enrollment_date, _ = _session_enrollment_latest_version(
         enrollments[experiment.name])
     enrollments[experiment.name] = (
         alternative, unused, timestamp_from_datetime(enrollment_date),
         timestamp_from_datetime(last_seen))
     self.session['experiments_enrollments'] = enrollments
Esempio n. 3
0
 def _set_last_seen(self, experiment, last_seen):
     enrollments = self.session.get("experiments_enrollments", {})
     alternative, unused, enrollment_date, _ = _session_enrollment_latest_version(enrollments[experiment.name])
     enrollments[experiment.name] = (
         alternative,
         unused,
         timestamp_from_datetime(enrollment_date),
         timestamp_from_datetime(last_seen),
     )
     self.session["experiments_enrollments"] = enrollments
Esempio n. 4
0
    def _set_enrollment(self, experiment, alternative, enrollment_date=None, last_seen=None):
        enrollments = self.session.get('experiments_enrollments', {})
        enrollments[experiment.name] = (alternative, None, timestamp_from_datetime(enrollment_date or now()), timestamp_from_datetime(last_seen))
        self.session['experiments_enrollments'] = enrollments
        if self._is_verified_human():
            self.experiment_counter.increment_participant_count(experiment, alternative, self._participant_identifier())
        else:
            logger.info(json.dumps({'type':'participant_unconfirmed', 'experiment': experiment.name, 'alternative': alternative, 'participant': self._participant_identifier()}))

        user_enrolled.send(self, experiment=experiment.name, alternative=alternative, user=None, session=self.session)
 def _set_enrollment(self, experiment, alternative, enrollment_date=None, last_seen=None):
     enrollments = self.session.get('experiments_enrollments', {})
     enrollments[experiment.name] = (alternative, None, timestamp_from_datetime(enrollment_date or now()), timestamp_from_datetime(last_seen))
     self.session['experiments_enrollments'] = enrollments
     if self._is_verified_human():
         self.experiment_counter.increment_participant_count(experiment, alternative, self._participant_identifier())
     user_enrolled.send(
         self,
         experiment=experiment.name, alternative=alternative,
         user=None, session=self.session)
Esempio n. 6
0
    def _set_enrollment(self, experiment, alternative, enrollment_date=None, last_seen=None):
        enrollments = self.session.get("experiments_enrollments", {})
        enrollments[experiment.name] = (
            alternative,
            None,
            timestamp_from_datetime(enrollment_date or now()),
            timestamp_from_datetime(last_seen),
        )
        self.session["experiments_enrollments"] = enrollments
        if self._is_verified_human():
            self.experiment_counter.increment_participant_count(experiment, alternative, self._participant_identifier())
        else:
            logger.info(
                json.dumps(
                    {
                        "type": "participant_unconfirmed",
                        "experiment": experiment.name,
                        "alternative": alternative,
                        "participant": self._participant_identifier(),
                    }
                )
            )

        user_enrolled.send(self, experiment=experiment.name, alternative=alternative, user=None, session=self.session)