@Override public List<Map> getImpressionRows(Experiment.ID experimentID, Parameters parameters) throws RepositoryException { try { //build and execute SQL queries for counts Date from_ts = parameters.getFromTime(); Date to_ts = parameters.getToTime(); String sqlBase = "bucket_label as bid, count(user_id) as c, count(distinct user_id) as cu"; String sqlParams = " where experiment_id = ? and context = ?"; List params = new ArrayList(); params.add(experimentID); params.add(parameters.getContext().getContext()); if (from_ts != null) { params.add(from_ts); sqlParams += " and timestamp >= ?"; } if (to_ts != null) { params.add(to_ts); sqlParams += " and timestamp <= ?"; } Object[] bucketSqlData = new Object[params.size()]; params.toArray(bucketSqlData); String sqlImpressions = "select " + sqlBase + " from event_impression" + sqlParams + " group by bucket_label"; List<Map> impressionRows = transaction.select(sqlImpressions, bucketSqlData); return impressionRows; } catch (Exception e) { throw new RepositoryException("error reading actions rows from MySQL", e); } }
boolean circumventRollup(final Experiment.ID experimentID, final Parameters parameters) { Experiment exp = getExperimentIfExists(experimentID); Date to = parameters.getToTime(); if (parameters.getFromTime() != null || parameters.getActions() != null) { return true; } else if (to != null) { // Get the date of the most recent rollup. Check to make sure that the toTime specified is >= last rollup // Return true if the date of the most recent rollup is before the specified toTime return analyticsRepository.checkMostRecentRollup(exp, parameters, to); } else { return false; } }
private Parameters createParameters(final Context context) { Parameters parameters = new Parameters(); parameters.setContext(context); return parameters; }
@Override public Object value(Transaction transaction) { ExperimentCounts counts = getExperimentRollup(experimentId, parameters); return calculateExperimentStatistics(counts, parameters.getMetricImpl(), parameters.getEffectSize(), parameters.getMode()); } });
Date start_ts = parameters.getFromTime(); Date end_ts = parameters.getToTime(); Parameters dailyParams = parameters.clone(); dailyParams.setFromTime(new Date(start_cal.getTime().getTime())); dailyParams.setToTime(new Date(to_cal.getTime().getTime())); Parameters cumulativeParams = parameters.clone(); cumulativeParams.setFromTime(null); cumulativeParams.setToTime(new Date(to_cal.getTime().getTime()));
List<Date> getDateHourRangeList(Experiment.ID experimentID, Parameters parameters) { final Experiment id = experimentRepository.getExperiment(experimentID); if (isNull(id)) { throw new ExperimentNotFoundException(experimentID); } final Optional<Date> from_ts = Optional.ofNullable(parameters.getFromTime()); final Optional<Date> to_ts = Optional.ofNullable(parameters.getToTime()); // Fetches the relevant partitions for a given time window where the user assignments data resides. return getUserAssignmentPartitions( from_ts.orElseGet(id::getCreationTime), to_ts.orElseGet(Date::new) ); }
Parameters parameters = new Parameters(); parameters.setTimeZone(getTimeZone(defaultTimezone)); parameters.setTimeZone(timeZone); Date fromDate = sdf.parse(fromStringDate); parameters.setFromTime(fromDate); } catch (ParseException e) { throw new TimeFormatException(fromStringDate); Date toDate = sdf.parse(toStringDate); parameters.setToTime(toDate); } catch (ParseException e) { throw new TimeFormatException(toStringDate);
parameters.getContext().getContext());
void addActionsToSql(Parameters parameters, StringBuilder sqlParams, List params) { List<String> actions = parameters.getActions(); if (actions != null) { int num_actions = actions.size(); if (num_actions >= 1) { sqlParams.append(" and action in (?"); params.add(actions.get(0)); } for (int num = 1; num < num_actions; num++) { sqlParams.append(",?"); params.add(actions.get(num)); } if (num_actions >= 1) { sqlParams.append(") "); } } }
return exportActions(experimentID, new Parameters(), authorizationHeader); } catch (Exception exception) { LOGGER.error("exportActions_get failed for experimentID={} with error:", experimentID, exception);
Date fromTs = parameters.getFromTime(); Date toTs = parameters.getToTime(); Timestamp fromTsNew = fromTs != null ? new Timestamp(fromTs.getTime()) : new Timestamp(id.getStartTime().getTime()); Timestamp toTsNew = toTs != null ? new Timestamp(toTs.getTime()) : new Timestamp(id.getEndTime().getTime());
final Parameters parameters) { BinomialMetric metric = parameters.getMetricImpl(); double effectSize = parameters.getEffectSize(); .withExperimentCounts(cumulativeCount) .withBuckets(calculateBucketStatistics(cumulativeCount.getBuckets(), metric, effectSize, parameters.getMode())) .build();
@Override public List<Map> getCountsFromRollups(Experiment.ID experimentID, Parameters parameters) throws RepositoryException { try { //build and execute SQL queries for counts from rollups String sqlQuery = "select day, bucket_label as bid, cumulative as c, action, impression_count as ic, " + "impression_user_count as iuc, action_count as ac, action_user_count as auc " + "from experiment_rollup where experiment_id = ? and context = ? order by day asc"; return transaction.select(sqlQuery, experimentID, parameters.getContext().getContext()); } catch (Exception e) { throw new RepositoryException("error reading counts from MySQL rollups", e); } }
Date from_ts = parameters.getFromTime(); Date to_ts = parameters.getToTime(); String sqlBase = "bucket_label as bid, count(user_id) as c, count(distinct user_id) as cu"; StringBuilder sqlParams = new StringBuilder(" where experiment_id = ? and context = ?"); List params = new ArrayList(); params.add(experimentID); params.add(parameters.getContext().getContext());
@Override public List<Map> getRollupRows(Experiment.ID experimentId, String rollupDate, Parameters parameters) throws RepositoryException { // TODO enable direct mapping of DateMidnight List rollupRows; try { //build and execute SQL queries for counts from rollups String sqlQuery = "select bucket_label as bid, action, impression_count as ic, impression_user_count as iuc, " + "action_count as ac, action_user_count as auc from experiment_rollup " + "where experiment_id = ? and cumulative = ? and day = ? and context = ?"; rollupRows = transaction.select(sqlQuery, experimentId, true, rollupDate, parameters.getContext().getContext()); return rollupRows; } catch (Exception e) { throw new RepositoryException("error reading rollup rows from MySQL", e); } }
Date from_ts = parameters.getFromTime(); Date to_ts = parameters.getToTime(); String sqlBase = "bucket_label as bid, count(user_id) as c, count(distinct user_id) as cu"; StringBuilder sqlParams = new StringBuilder(" where experiment_id = ? and context = ?"); List params = new ArrayList(); params.add(experimentID); params.add(parameters.getContext().getContext());
/** * Retrieves the analytics data for the buckets and the experiment itself. * * @param experimentDetail the {@link ExperimentDetail} that needs to be enhanced with analytics data * @param params {@link Parameters} for the Analytics calls- containing the context for example * @return the same object with additional analytic information */ ExperimentDetail getAnalyticData(ExperimentDetail experimentDetail, Parameters params) { // analytics data is only necessary for running/paused/terminated experiments if (!experimentDetail.getState().equals(Experiment.State.DRAFT)) { //experiment level analytics AssignmentCounts assignmentCounts = analytics.getAssignmentCounts(experimentDetail.getId(), params.getContext()); if (!Objects.isNull(assignmentCounts)) { long onlyBucketAssignments = assignmentCounts.getTotalUsers().getBucketAssignments(); experimentDetail.setTotalNumberUsers(onlyBucketAssignments); } ExperimentStatistics expStats = analytics.getExperimentStatistics(experimentDetail.getId(), params); getBucketDetails(experimentDetail, expStats, assignmentCounts); } return experimentDetail; }