<commit_before>/**
 * Copyright (c) 2015 - The CM Authors <<EMAIL>>
 *   All Rights Reserved.
 *
 * This file is CONFIDENTIAL -- Distribution or duplication of this material or
 * the information contained herein is strictly forbidden unless prior written
 * permission is obtained.
 */
#ifndef _CM_TRACKEDSESSION_H
#define _CM_TRACKEDSESSION_H
#include <mutex>
#include <stdlib.h>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
#include <fnord/base/datetime.h>

#include "itemref.h"
#include "trackedquery.h"

namespace cm {
class CustomerNamespace;

/**
 * The max time after which a click on a query result is considered a click
 */
static const uint64_t kMaxQueryClickDelaySeconds = 6 * 5;

/**
 * Flush/expire a session after N seconds of inactivity
 */
static const uint64_t kSessionIdleTimeoutSeconds = 6 * 10;

/**
 * A tracked session. Make sure to hold the mutex when updating or accessing
 * any of the fields.
 */
struct TrackedSession {
  std::string customer_key;
  std::unordered_map<std::string, TrackedQuery> queries;
  std::unordered_map<std::string, TrackedItemVisit> item_visits;
  uint64_t last_seen_unix_micros;
  std::mutex mutex;

  /**
   * Trigger an update to incorporate new information. This will e.g. mark
   * query items as clicked if a corresponding click was observed.
   *
   * required precondition: must hold the session mutex
   */
  void update();

  void debugPrint(const std::string& uid) const;

};

} // namespace cm
#endif
<commit_msg>fix logjoin params<commit_after>/**
 * Copyright (c) 2015 - The CM Authors <<EMAIL>>
 *   All Rights Reserved.
 *
 * This file is CONFIDENTIAL -- Distribution or duplication of this material or
 * the information contained herein is strictly forbidden unless prior written
 * permission is obtained.
 */
#ifndef _CM_TRACKEDSESSION_H
#define _CM_TRACKEDSESSION_H
#include <mutex>
#include <stdlib.h>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
#include <fnord/base/datetime.h>

#include "itemref.h"
#include "trackedquery.h"

namespace cm {
class CustomerNamespace;

/**
 * The max time after which a click on a query result is considered a click
 */
static const uint64_t kMaxQueryClickDelaySeconds = 180;

/**
 * Flush/expire a session after N seconds of inactivity
 */
static const uint64_t kSessionIdleTimeoutSeconds = 60 * 90;

/**
 * A tracked session. Make sure to hold the mutex when updating or accessing
 * any of the fields.
 */
struct TrackedSession {
  std::string customer_key;
  std::unordered_map<std::string, TrackedQuery> queries;
  std::unordered_map<std::string, TrackedItemVisit> item_visits;
  uint64_t last_seen_unix_micros;
  std::mutex mutex;

  /**
   * Trigger an update to incorporate new information. This will e.g. mark
   * query items as clicked if a corresponding click was observed.
   *
   * required precondition: must hold the session mutex
   */
  void update();

  void debugPrint(const std::string& uid) const;

};

} // namespace cm
#endif

{'fraction_non_alphanumeric': 0.09437086092715231, 'fraction_numerical': 0.010596026490066225, 'mean_word_length': 4.2907180385288965, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3685511', 'n_tokens_mistral': 954, 'n_tokens_neox': 909, 'n_words': 331}