Skip to content

Commit

Permalink
Merge pull request #52 from o19s/impression
Browse files Browse the repository at this point in the history
Changes view to impression
  • Loading branch information
wrigleyDan authored Dec 9, 2024
2 parents c8643c9 + 3b6be95 commit 6498693
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ public class CoecClickModel extends ClickModel {

// UBI event names.
public static final String EVENT_CLICK = "click";
// TODO: Change "view" to "impression".
public static final String EVENT_VIEW = "view";
public static final String EVENT_IMPRESSION = "impression";

private final CoecClickModelParameters parameters;

Expand Down Expand Up @@ -192,7 +191,7 @@ private Map<String, Set<ClickthroughRate>> getClickthroughRate(final int maxRank
* },
* {
* "term": {
* "action_name": "view"
* "action_name": "impression"
* }
* }
* ],
Expand All @@ -219,7 +218,7 @@ private Map<String, Set<ClickthroughRate>> getClickthroughRate(final int maxRank
" },\n" +
" {\n" +
" \"term\": {\n" +
" \"action_name\": \"view\"\n" +
" \"action_name\": \"impression\"\n" +
" }\n" +
" }\n" +
" ],\n" +
Expand Down Expand Up @@ -355,8 +354,8 @@ public Map<Integer, Double> getRankAggregatedClickThrough() throws Exception {

}

// Handle the "view" bucket.
if(EVENT_VIEW.equalsIgnoreCase(actionBucket.getKey().toString())) {
// Handle the "impression" bucket.
if(EVENT_IMPRESSION.equalsIgnoreCase(actionBucket.getKey().toString())) {

final Terms positionTerms = actionBucket.getAggregations().get("By_Position");
final Collection<? extends Terms.Bucket> positionBuckets = positionTerms.getBuckets();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public long getCountOfQueriesForUserQueryHavingResultInRankR(final String userQu
// Get all query IDs matching this user query.
final Collection<String> queryIds = getQueryIdsHavingUserQuery(userQuery);

// For each query ID, get the events with action_name = "view" having a match on objectId and rank (position).
// For each query ID, get the events with action_name = "impression" having a match on objectId and rank (position).
for(final String queryId : queryIds) {

//LOGGER.info("userQuery = {}; queryId = {}; objectId = {}; rank = {}", userQuery, queryId, objectId, rank);
Expand All @@ -160,7 +160,7 @@ public long getCountOfQueriesForUserQueryHavingResultInRankR(final String userQu
" },\n" +
" {\n" +
" \"term\": {\n" +
" \"action_name\": \"view\"\n" +
" \"action_name\": \"impression\"\n" +
" }\n" +
" },\n" +
" {\n" +
Expand Down Expand Up @@ -204,7 +204,10 @@ public long getCountOfQueriesForUserQueryHavingResultInRankR(final String userQu

//LOGGER.info("Query ID: {} --- Count of {} having {} at rank {} = {}", queryId, userQuery, objectId, rank, response.getHits().getTotalHits().value);

countOfTimesShownAtRank += response.getHits().getTotalHits().value;
// Won't be null as long as trackTotalHits is true.
if(response.getHits().getTotalHits() != null) {
countOfTimesShownAtRank += response.getHits().getTotalHits().value;
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public final Collection<Map<String, Long>> getQuerySet(final String querySetId)
LOGGER.error("Unable to get query set with ID {}", querySetId);

// The query set was not found.
throw new RuntimeException("The query set with ID " + querySetId + " was not found.");
throw new RuntimeException("The query set with ID " + querySetId + " was not found.");

}

Expand Down

0 comments on commit 6498693

Please sign in to comment.