PLACE_COLUMN_WIFI_APS " STRING, "\
PLACE_COLUMN_CREATE_DATE " timestamp"
-bool ctx::PlacesDetector::onTimerExpired(int timerId) {
- _D("");
- detectPlaces();
- return true;
-}
-
void ctx::PlacesDetector::detectPlaces()
{
_D("");
+ __dbCreateTable();
__dbDeletePlaces();
__dbDeleteOldEntries();
std::vector<Json> records = __dbGetVisits();
_D("Visits number from %d to %d (to short and to long reduction)", size, newSize);
}
-std::vector<std::shared_ptr<ctx::Place>> ctx::PlacesDetector::__processVisits(ctx::Visits &visits)
+std::vector<std::shared_ptr<ctx::Place>> ctx::PlacesDetector::__processVisits(ctx::Visits &visits, bool testMode)
{
#ifdef TIZEN_ENGINEER_MODE
std::vector<Visits> placesVisits; // TODO: remove from final solution.
for (std::shared_ptr<graph::Component> component : *components) {
// Small places outliers reduction
- if (!__testMode && component->size() < PLACES_DETECTOR_MIN_VISITS_PER_BIG_PLACE)
+ if (!testMode && component->size() < PLACES_DETECTOR_MIN_VISITS_PER_BIG_PLACE)
continue;
std::shared_ptr<Visits> merged = std::make_shared<Visits>();
for (graph::Node i : *component) {
if (place->categId == PLACE_CATEG_ID_NONE)
continue;
newDetectedPlaces.push_back(place);
- if (!__testMode)
+ if (!testMode)
__dbInsertPlace(*place);
#ifdef TIZEN_ENGINEER_MODE
_D("deleting Wifi APs older than: %d, result: %s", threshold, ret ? "SUCCESS" : "FAIL");
}
-ctx::PlacesDetector::PlacesDetector(bool testMode):
- __testMode(testMode)
-{
- if (testMode)
- return;
- __dbCreateTable();
-}
-
void ctx::PlacesDetector::__dbCreateTable()
{
DatabaseManager dbManager;
extern "C" SO_EXPORT void detectPlaces()
{
- _D("");
- ctx::PlacesDetector placesDetector;
- placesDetector.detectPlaces();
+ ctx::PlacesDetector::detectPlaces();
}
#include <vector>
#include <cstdint>
-#include <ITimerListener.h>
#include <UserPlacesTypes.h>
#include <MyPlaceTypes.h>
#include "Graph.h"
namespace ctx {
- class PlacesDetector : public ITimerListener {
+ class PlacesDetector {
private:
- bool __testMode;
-
- double __doubleValueFromJson(Json &row, const char* key);
- Categs __visitCategsFromJson(Json &row);
- void __visitLocationFromJson(Json &row, ctx::Visit &visit);
- Visit __visitFromJson(Json &row);
- Visits __visitsFromJsons(std::vector<Json>& records);
-
- std::shared_ptr<graph::Graph> __graphFromVisits(const std::vector<Visit> &visits);
-
- void __dbCreateTable();
- void __dbDeletePlaces();
- void __dbDeleteOldEntries();
- void __dbDeleteOlderVisitsThan(time_t threshold);
- void __dbDeleteOlderWifiAPsThan(time_t threshold);
- std::vector<Json> __dbGetVisits();
- void __dbInsertPlace(const Place &place);
-
- std::shared_ptr<Place> __placeFromMergedVisits(Visits &mergedVisits);
- std::vector<std::shared_ptr<ctx::Place>> __processVisits(Visits &visits);
+ static double __doubleValueFromJson(Json &row, const char* key);
+ static Categs __visitCategsFromJson(Json &row);
+ static void __visitLocationFromJson(Json &row, ctx::Visit &visit);
+ static Visit __visitFromJson(Json &row);
+ static Visits __visitsFromJsons(std::vector<Json>& records);
+
+ static std::shared_ptr<graph::Graph> __graphFromVisits(const std::vector<Visit> &visits);
+
+ static void __dbCreateTable();
+ static void __dbDeletePlaces();
+ static void __dbDeleteOldEntries();
+ static void __dbDeleteOlderVisitsThan(time_t threshold);
+ static void __dbDeleteOlderWifiAPsThan(time_t threshold);
+ static std::vector<Json> __dbGetVisits();
+ static void __dbInsertPlace(const Place &place);
+
+ static std::shared_ptr<Place> __placeFromMergedVisits(Visits &mergedVisits);
+ static std::vector<std::shared_ptr<ctx::Place>> __processVisits(Visits &visits, bool testMode = false);
static void __mergeLocation(const Visits &mergedVisits, Place &place);
- std::shared_ptr<graph::Components> __mergeVisits(const std::vector<Visit> &visits);
+ static std::shared_ptr<graph::Components> __mergeVisits(const std::vector<Visit> &visits);
static void __reduceOutliers(Visits &visits);
static void __reduceOutliers(std::shared_ptr<graph::Components> &cc);
- bool onTimerExpired(int timerId);
+ PlacesDetector();
public:
- PlacesDetector(bool testMode = false);
- void detectPlaces();
+ static void detectPlaces();
}; /* class PlacesDetector */