Changeset View
Changeset View
Standalone View
Standalone View
src/service/plugins/sqlite/StatsPlugin.cpp
Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | 57 | { | |||
---|---|---|---|---|---|
64 | 64 | | |||
65 | setName(QStringLiteral("org.kde.ActivityManager.Resources.Scoring")); | 65 | setName(QStringLiteral("org.kde.ActivityManager.Resources.Scoring")); | ||
66 | } | 66 | } | ||
67 | 67 | | |||
68 | bool StatsPlugin::init(QHash<QString, QObject *> &modules) | 68 | bool StatsPlugin::init(QHash<QString, QObject *> &modules) | ||
69 | { | 69 | { | ||
70 | Plugin::init(modules); | 70 | Plugin::init(modules); | ||
71 | 71 | | |||
72 | if (!resourcesDatabase()) { | ||||
73 | return false; | ||||
74 | } | ||||
75 | | ||||
72 | m_activities = modules[QStringLiteral("activities")]; | 76 | m_activities = modules[QStringLiteral("activities")]; | ||
73 | m_resources = modules[QStringLiteral("resources")]; | 77 | m_resources = modules[QStringLiteral("resources")]; | ||
74 | 78 | | |||
75 | m_resourceLinking->init(); | 79 | m_resourceLinking->init(); | ||
76 | 80 | | |||
77 | // Initializing the database | | |||
78 | resourcesDatabase(); | | |||
79 | | ||||
80 | connect(m_resources, SIGNAL(ProcessedResourceEvents(EventList)), | 81 | connect(m_resources, SIGNAL(ProcessedResourceEvents(EventList)), | ||
81 | this, SLOT(addEvents(EventList))); | 82 | this, SLOT(addEvents(EventList))); | ||
82 | connect(m_resources, SIGNAL(RegisteredResourceMimetype(QString, QString)), | 83 | connect(m_resources, SIGNAL(RegisteredResourceMimetype(QString, QString)), | ||
83 | this, SLOT(saveResourceMimetype(QString, QString))); | 84 | this, SLOT(saveResourceMimetype(QString, QString))); | ||
84 | connect(m_resources, SIGNAL(RegisteredResourceTitle(QString, QString)), | 85 | connect(m_resources, SIGNAL(RegisteredResourceTitle(QString, QString)), | ||
85 | this, SLOT(saveResourceTitle(QString, QString))); | 86 | this, SLOT(saveResourceTitle(QString, QString))); | ||
86 | 87 | | |||
87 | connect(modules[QStringLiteral("config")], SIGNAL(pluginConfigChanged()), | 88 | connect(modules[QStringLiteral("config")], SIGNAL(pluginConfigChanged()), | ||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | 160 | Q_ASSERT_X(!usedActivity.isEmpty(), | |||
160 | "StatsPlugin::openResourceEvent", | 161 | "StatsPlugin::openResourceEvent", | ||
161 | "Activity shoud not be empty"); | 162 | "Activity shoud not be empty"); | ||
162 | Q_ASSERT_X(!targettedResource.isEmpty(), | 163 | Q_ASSERT_X(!targettedResource.isEmpty(), | ||
163 | "StatsPlugin::openResourceEvent", | 164 | "StatsPlugin::openResourceEvent", | ||
164 | "Resource shoud not be empty"); | 165 | "Resource shoud not be empty"); | ||
165 | 166 | | |||
166 | detectResourceInfo(targettedResource); | 167 | detectResourceInfo(targettedResource); | ||
167 | 168 | | |||
168 | Utils::prepare(resourcesDatabase(), openResourceEventQuery, QStringLiteral( | 169 | Utils::prepare(*resourcesDatabase(), openResourceEventQuery, QStringLiteral( | ||
169 | "INSERT INTO ResourceEvent" | 170 | "INSERT INTO ResourceEvent" | ||
170 | " (usedActivity, initiatingAgent, targettedResource, start, end) " | 171 | " (usedActivity, initiatingAgent, targettedResource, start, end) " | ||
171 | "VALUES (:usedActivity, :initiatingAgent, :targettedResource, :start, :end)" | 172 | "VALUES (:usedActivity, :initiatingAgent, :targettedResource, :start, :end)" | ||
172 | )); | 173 | )); | ||
173 | 174 | | |||
174 | Utils::exec(Utils::FailOnError, *openResourceEventQuery, | 175 | Utils::exec(Utils::FailOnError, *openResourceEventQuery, | ||
175 | ":usedActivity" , usedActivity , | 176 | ":usedActivity" , usedActivity , | ||
176 | ":initiatingAgent" , initiatingAgent , | 177 | ":initiatingAgent" , initiatingAgent , | ||
Show All 13 Lines | 189 | Q_ASSERT_X(!initiatingAgent.isEmpty(), | |||
190 | "Agent shoud not be empty"); | 191 | "Agent shoud not be empty"); | ||
191 | Q_ASSERT_X(!usedActivity.isEmpty(), | 192 | Q_ASSERT_X(!usedActivity.isEmpty(), | ||
192 | "StatsPlugin::closeResourceEvent", | 193 | "StatsPlugin::closeResourceEvent", | ||
193 | "Activity shoud not be empty"); | 194 | "Activity shoud not be empty"); | ||
194 | Q_ASSERT_X(!targettedResource.isEmpty(), | 195 | Q_ASSERT_X(!targettedResource.isEmpty(), | ||
195 | "StatsPlugin::closeResourceEvent", | 196 | "StatsPlugin::closeResourceEvent", | ||
196 | "Resource shoud not be empty"); | 197 | "Resource shoud not be empty"); | ||
197 | 198 | | |||
198 | Utils::prepare(resourcesDatabase(), closeResourceEventQuery, QStringLiteral( | 199 | Utils::prepare(*resourcesDatabase(), closeResourceEventQuery, QStringLiteral( | ||
199 | "UPDATE ResourceEvent " | 200 | "UPDATE ResourceEvent " | ||
200 | "SET end = :end " | 201 | "SET end = :end " | ||
201 | "WHERE " | 202 | "WHERE " | ||
202 | ":usedActivity = usedActivity AND " | 203 | ":usedActivity = usedActivity AND " | ||
203 | ":initiatingAgent = initiatingAgent AND " | 204 | ":initiatingAgent = initiatingAgent AND " | ||
204 | ":targettedResource = targettedResource AND " | 205 | ":targettedResource = targettedResource AND " | ||
205 | "end IS NULL" | 206 | "end IS NULL" | ||
206 | )); | 207 | )); | ||
Show All 24 Lines | 229 | if (insertResourceInfo(file)) { | |||
231 | const auto text = item.text(); | 232 | const auto text = item.text(); | ||
232 | saveResourceTitle(file, text.isEmpty() ? _uri : text, true); | 233 | saveResourceTitle(file, text.isEmpty() ? _uri : text, true); | ||
233 | } | 234 | } | ||
234 | } | 235 | } | ||
235 | 236 | | |||
236 | bool StatsPlugin::insertResourceInfo(const QString &uri) | 237 | bool StatsPlugin::insertResourceInfo(const QString &uri) | ||
237 | { | 238 | { | ||
238 | 239 | | |||
239 | Utils::prepare(resourcesDatabase(), getResourceInfoQuery, QStringLiteral( | 240 | Utils::prepare(*resourcesDatabase(), getResourceInfoQuery, QStringLiteral( | ||
240 | "SELECT targettedResource FROM ResourceInfo WHERE " | 241 | "SELECT targettedResource FROM ResourceInfo WHERE " | ||
241 | " targettedResource = :targettedResource " | 242 | " targettedResource = :targettedResource " | ||
242 | )); | 243 | )); | ||
243 | 244 | | |||
244 | getResourceInfoQuery->bindValue(":targettedResource", uri); | 245 | getResourceInfoQuery->bindValue(":targettedResource", uri); | ||
245 | Utils::exec(Utils::FailOnError, *getResourceInfoQuery); | 246 | Utils::exec(Utils::FailOnError, *getResourceInfoQuery); | ||
246 | 247 | | |||
247 | if (getResourceInfoQuery->next()) { | 248 | if (getResourceInfoQuery->next()) { | ||
248 | return false; | 249 | return false; | ||
249 | } | 250 | } | ||
250 | 251 | | |||
251 | Utils::prepare(resourcesDatabase(), insertResourceInfoQuery, QStringLiteral( | 252 | Utils::prepare(*resourcesDatabase(), insertResourceInfoQuery, QStringLiteral( | ||
252 | "INSERT INTO ResourceInfo( " | 253 | "INSERT INTO ResourceInfo( " | ||
253 | " targettedResource" | 254 | " targettedResource" | ||
254 | ", title" | 255 | ", title" | ||
255 | ", autoTitle" | 256 | ", autoTitle" | ||
256 | ", mimetype" | 257 | ", mimetype" | ||
257 | ", autoMimetype" | 258 | ", autoMimetype" | ||
258 | ") VALUES (" | 259 | ") VALUES (" | ||
259 | " :targettedResource" | 260 | " :targettedResource" | ||
Show All 11 Lines | |||||
271 | return true; | 272 | return true; | ||
272 | } | 273 | } | ||
273 | 274 | | |||
274 | void StatsPlugin::saveResourceTitle(const QString &uri, const QString &title, | 275 | void StatsPlugin::saveResourceTitle(const QString &uri, const QString &title, | ||
275 | bool autoTitle) | 276 | bool autoTitle) | ||
276 | { | 277 | { | ||
277 | insertResourceInfo(uri); | 278 | insertResourceInfo(uri); | ||
278 | 279 | | |||
279 | DATABASE_TRANSACTION(resourcesDatabase()); | 280 | DATABASE_TRANSACTION(*resourcesDatabase()); | ||
280 | 281 | | |||
281 | Utils::prepare(resourcesDatabase(), saveResourceTitleQuery, QStringLiteral( | 282 | Utils::prepare(*resourcesDatabase(), saveResourceTitleQuery, QStringLiteral( | ||
282 | "UPDATE ResourceInfo SET " | 283 | "UPDATE ResourceInfo SET " | ||
283 | " title = :title" | 284 | " title = :title" | ||
284 | ", autoTitle = :autoTitle " | 285 | ", autoTitle = :autoTitle " | ||
285 | "WHERE " | 286 | "WHERE " | ||
286 | "targettedResource = :targettedResource " | 287 | "targettedResource = :targettedResource " | ||
287 | )); | 288 | )); | ||
288 | 289 | | |||
289 | Utils::exec(Utils::FailOnError, *saveResourceTitleQuery, | 290 | Utils::exec(Utils::FailOnError, *saveResourceTitleQuery, | ||
290 | ":targettedResource" , uri , | 291 | ":targettedResource" , uri , | ||
291 | ":title" , title , | 292 | ":title" , title , | ||
292 | ":autoTitle" , (autoTitle ? "1" : "0") | 293 | ":autoTitle" , (autoTitle ? "1" : "0") | ||
293 | ); | 294 | ); | ||
294 | } | 295 | } | ||
295 | 296 | | |||
296 | void StatsPlugin::saveResourceMimetype(const QString &uri, | 297 | void StatsPlugin::saveResourceMimetype(const QString &uri, | ||
297 | const QString &mimetype, | 298 | const QString &mimetype, | ||
298 | bool autoMimetype) | 299 | bool autoMimetype) | ||
299 | { | 300 | { | ||
300 | insertResourceInfo(uri); | 301 | insertResourceInfo(uri); | ||
301 | 302 | | |||
302 | DATABASE_TRANSACTION(resourcesDatabase()); | 303 | DATABASE_TRANSACTION(*resourcesDatabase()); | ||
303 | 304 | | |||
304 | Utils::prepare(resourcesDatabase(), saveResourceMimetypeQuery, QStringLiteral( | 305 | Utils::prepare(*resourcesDatabase(), saveResourceMimetypeQuery, QStringLiteral( | ||
305 | "UPDATE ResourceInfo SET " | 306 | "UPDATE ResourceInfo SET " | ||
306 | " mimetype = :mimetype" | 307 | " mimetype = :mimetype" | ||
307 | ", autoMimetype = :autoMimetype " | 308 | ", autoMimetype = :autoMimetype " | ||
308 | "WHERE " | 309 | "WHERE " | ||
309 | "targettedResource = :targettedResource " | 310 | "targettedResource = :targettedResource " | ||
310 | )); | 311 | )); | ||
311 | 312 | | |||
312 | Utils::exec(Utils::FailOnError, *saveResourceMimetypeQuery, | 313 | Utils::exec(Utils::FailOnError, *saveResourceMimetypeQuery, | ||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | 383 | { | |||
387 | } | 388 | } | ||
388 | 389 | | |||
389 | const auto &eventsToProcess = | 390 | const auto &eventsToProcess = | ||
390 | events | transformed(&StatsPlugin::validateEvent, this) | 391 | events | transformed(&StatsPlugin::validateEvent, this) | ||
391 | | filtered(&StatsPlugin::acceptedEvent, this); | 392 | | filtered(&StatsPlugin::acceptedEvent, this); | ||
392 | 393 | | |||
393 | if (eventsToProcess.begin() == eventsToProcess.end()) return; | 394 | if (eventsToProcess.begin() == eventsToProcess.end()) return; | ||
394 | 395 | | |||
395 | DATABASE_TRANSACTION(resourcesDatabase()); | 396 | DATABASE_TRANSACTION(*resourcesDatabase()); | ||
396 | 397 | | |||
397 | for (auto event : eventsToProcess) { | 398 | for (auto event : eventsToProcess) { | ||
398 | 399 | | |||
399 | switch (event.type) { | 400 | switch (event.type) { | ||
400 | case Event::Accessed: | 401 | case Event::Accessed: | ||
401 | openResourceEvent( | 402 | openResourceEvent( | ||
402 | currentActivity(), event.application, event.uri, | 403 | currentActivity(), event.application, event.uri, | ||
403 | event.timestamp, event.timestamp); | 404 | event.timestamp, event.timestamp); | ||
Show All 35 Lines | 439 | void StatsPlugin::DeleteRecentStats(const QString &activity, int count, | |||
439 | const QString &what) | 440 | const QString &what) | ||
440 | { | 441 | { | ||
441 | const auto usedActivity = activity.isEmpty() ? QVariant() | 442 | const auto usedActivity = activity.isEmpty() ? QVariant() | ||
442 | : QVariant(activity); | 443 | : QVariant(activity); | ||
443 | 444 | | |||
444 | // If we need to delete everything, | 445 | // If we need to delete everything, | ||
445 | // no need to bother with the count and the date | 446 | // no need to bother with the count and the date | ||
446 | 447 | | |||
447 | DATABASE_TRANSACTION(resourcesDatabase()); | 448 | DATABASE_TRANSACTION(*resourcesDatabase()); | ||
448 | 449 | | |||
449 | if (what == QStringLiteral("everything")) { | 450 | if (what == QStringLiteral("everything")) { | ||
450 | // Instantiating these every time is not a big overhead | 451 | // Instantiating these every time is not a big overhead | ||
451 | // since this method is rarely executed. | 452 | // since this method is rarely executed. | ||
452 | 453 | | |||
453 | auto removeEventsQuery = resourcesDatabase().createQuery(); | 454 | auto removeEventsQuery = resourcesDatabase()->createQuery(); | ||
454 | removeEventsQuery.prepare( | 455 | removeEventsQuery.prepare( | ||
455 | "DELETE FROM ResourceEvent " | 456 | "DELETE FROM ResourceEvent " | ||
456 | "WHERE usedActivity = COALESCE(:usedActivity, usedActivity)" | 457 | "WHERE usedActivity = COALESCE(:usedActivity, usedActivity)" | ||
457 | ); | 458 | ); | ||
458 | 459 | | |||
459 | auto removeScoreCachesQuery = resourcesDatabase().createQuery(); | 460 | auto removeScoreCachesQuery = resourcesDatabase()->createQuery(); | ||
460 | removeScoreCachesQuery.prepare( | 461 | removeScoreCachesQuery.prepare( | ||
461 | "DELETE FROM ResourceScoreCache " | 462 | "DELETE FROM ResourceScoreCache " | ||
462 | "WHERE usedActivity = COALESCE(:usedActivity, usedActivity)"); | 463 | "WHERE usedActivity = COALESCE(:usedActivity, usedActivity)"); | ||
463 | 464 | | |||
464 | Utils::exec(Utils::FailOnError, removeEventsQuery, ":usedActivity", usedActivity); | 465 | Utils::exec(Utils::FailOnError, removeEventsQuery, ":usedActivity", usedActivity); | ||
465 | Utils::exec(Utils::FailOnError, removeScoreCachesQuery, ":usedActivity", usedActivity); | 466 | Utils::exec(Utils::FailOnError, removeScoreCachesQuery, ":usedActivity", usedActivity); | ||
466 | 467 | | |||
467 | } else { | 468 | } else { | ||
468 | 469 | | |||
469 | // Deleting a specified length of time | 470 | // Deleting a specified length of time | ||
470 | 471 | | |||
471 | auto since = QDateTime::currentDateTime(); | 472 | auto since = QDateTime::currentDateTime(); | ||
472 | 473 | | |||
473 | since = (what[0] == QLatin1Char('h')) ? since.addSecs(-count * 60 * 60) | 474 | since = (what[0] == QLatin1Char('h')) ? since.addSecs(-count * 60 * 60) | ||
474 | : (what[0] == QLatin1Char('d')) ? since.addDays(-count) | 475 | : (what[0] == QLatin1Char('d')) ? since.addDays(-count) | ||
475 | : (what[0] == QLatin1Char('m')) ? since.addMonths(-count) | 476 | : (what[0] == QLatin1Char('m')) ? since.addMonths(-count) | ||
476 | : since; | 477 | : since; | ||
477 | 478 | | |||
478 | // Maybe we should decrease the scores for the previously | 479 | // Maybe we should decrease the scores for the previously | ||
479 | // cached items. Thinking it is not that important - | 480 | // cached items. Thinking it is not that important - | ||
480 | // if something was accessed before, and the user did not | 481 | // if something was accessed before, and the user did not | ||
481 | // remove the history, it is not really a secret. | 482 | // remove the history, it is not really a secret. | ||
482 | 483 | | |||
483 | auto removeEventsQuery = resourcesDatabase().createQuery(); | 484 | auto removeEventsQuery = resourcesDatabase()->createQuery(); | ||
484 | removeEventsQuery.prepare( | 485 | removeEventsQuery.prepare( | ||
485 | "DELETE FROM ResourceEvent " | 486 | "DELETE FROM ResourceEvent " | ||
486 | "WHERE usedActivity = COALESCE(:usedActivity, usedActivity) " | 487 | "WHERE usedActivity = COALESCE(:usedActivity, usedActivity) " | ||
487 | "AND end > :since" | 488 | "AND end > :since" | ||
488 | ); | 489 | ); | ||
489 | 490 | | |||
490 | auto removeScoreCachesQuery = resourcesDatabase().createQuery(); | 491 | auto removeScoreCachesQuery = resourcesDatabase()->createQuery(); | ||
491 | removeScoreCachesQuery.prepare( | 492 | removeScoreCachesQuery.prepare( | ||
492 | "DELETE FROM ResourceScoreCache " | 493 | "DELETE FROM ResourceScoreCache " | ||
493 | "WHERE usedActivity = COALESCE(:usedActivity, usedActivity) " | 494 | "WHERE usedActivity = COALESCE(:usedActivity, usedActivity) " | ||
494 | "AND firstUpdate > :since"); | 495 | "AND firstUpdate > :since"); | ||
495 | 496 | | |||
496 | Utils::exec(Utils::FailOnError, removeEventsQuery, | 497 | Utils::exec(Utils::FailOnError, removeEventsQuery, | ||
497 | ":usedActivity", usedActivity, | 498 | ":usedActivity", usedActivity, | ||
498 | ":since", since.toTime_t() | 499 | ":since", since.toTime_t() | ||
Show All 11 Lines | |||||
510 | void StatsPlugin::DeleteEarlierStats(const QString &activity, int months) | 511 | void StatsPlugin::DeleteEarlierStats(const QString &activity, int months) | ||
511 | { | 512 | { | ||
512 | if (months == 0) { | 513 | if (months == 0) { | ||
513 | return; | 514 | return; | ||
514 | } | 515 | } | ||
515 | 516 | | |||
516 | // Deleting a specified length of time | 517 | // Deleting a specified length of time | ||
517 | 518 | | |||
518 | DATABASE_TRANSACTION(resourcesDatabase()); | 519 | DATABASE_TRANSACTION(*resourcesDatabase()); | ||
519 | 520 | | |||
520 | const auto time = QDateTime::currentDateTime().addMonths(-months); | 521 | const auto time = QDateTime::currentDateTime().addMonths(-months); | ||
521 | const auto usedActivity = activity.isEmpty() ? QVariant() | 522 | const auto usedActivity = activity.isEmpty() ? QVariant() | ||
522 | : QVariant(activity); | 523 | : QVariant(activity); | ||
523 | 524 | | |||
524 | auto removeEventsQuery = resourcesDatabase().createQuery(); | 525 | auto removeEventsQuery = resourcesDatabase()->createQuery(); | ||
525 | removeEventsQuery.prepare( | 526 | removeEventsQuery.prepare( | ||
526 | "DELETE FROM ResourceEvent " | 527 | "DELETE FROM ResourceEvent " | ||
527 | "WHERE usedActivity = COALESCE(:usedActivity, usedActivity) " | 528 | "WHERE usedActivity = COALESCE(:usedActivity, usedActivity) " | ||
528 | "AND start < :time" | 529 | "AND start < :time" | ||
529 | ); | 530 | ); | ||
530 | 531 | | |||
531 | auto removeScoreCachesQuery = resourcesDatabase().createQuery(); | 532 | auto removeScoreCachesQuery = resourcesDatabase()->createQuery(); | ||
532 | removeScoreCachesQuery.prepare( | 533 | removeScoreCachesQuery.prepare( | ||
533 | "DELETE FROM ResourceScoreCache " | 534 | "DELETE FROM ResourceScoreCache " | ||
534 | "WHERE usedActivity = COALESCE(:usedActivity, usedActivity) " | 535 | "WHERE usedActivity = COALESCE(:usedActivity, usedActivity) " | ||
535 | "AND lastUpdate < :time"); | 536 | "AND lastUpdate < :time"); | ||
536 | 537 | | |||
537 | Utils::exec(Utils::FailOnError, removeEventsQuery, | 538 | Utils::exec(Utils::FailOnError, removeEventsQuery, | ||
538 | ":usedActivity", usedActivity, | 539 | ":usedActivity", usedActivity, | ||
539 | ":time", time.toTime_t() | 540 | ":time", time.toTime_t() | ||
Show All 19 Lines | 558 | Q_ASSERT_X(!activity.isEmpty(), | |||
559 | "Activity shoud not be empty"); | 560 | "Activity shoud not be empty"); | ||
560 | Q_ASSERT_X(!resource.isEmpty(), | 561 | Q_ASSERT_X(!resource.isEmpty(), | ||
561 | "StatsPlugin::DeleteStatsForResource", | 562 | "StatsPlugin::DeleteStatsForResource", | ||
562 | "Resource shoud not be empty"); | 563 | "Resource shoud not be empty"); | ||
563 | Q_ASSERT_X(client != CURRENT_AGENT_TAG, | 564 | Q_ASSERT_X(client != CURRENT_AGENT_TAG, | ||
564 | "StatsPlugin::DeleteStatsForResource", | 565 | "StatsPlugin::DeleteStatsForResource", | ||
565 | "We can not handle CURRENT_AGENT_TAG here"); | 566 | "We can not handle CURRENT_AGENT_TAG here"); | ||
566 | 567 | | |||
567 | DATABASE_TRANSACTION(resourcesDatabase()); | 568 | DATABASE_TRANSACTION(*resourcesDatabase()); | ||
568 | 569 | | |||
569 | // Check against sql injection | 570 | // Check against sql injection | ||
570 | if (activity.contains('\'') || client.contains('\'')) return; | 571 | if (activity.contains('\'') || client.contains('\'')) return; | ||
571 | 572 | | |||
572 | const auto activityFilter = | 573 | const auto activityFilter = | ||
573 | activity == ANY_ACTIVITY_TAG ? " 1 " : | 574 | activity == ANY_ACTIVITY_TAG ? " 1 " : | ||
574 | QStringLiteral(" usedActivity = '%1' ").arg( | 575 | QStringLiteral(" usedActivity = '%1' ").arg( | ||
575 | activity == CURRENT_ACTIVITY_TAG ? | 576 | activity == CURRENT_ACTIVITY_TAG ? | ||
576 | currentActivity() : activity | 577 | currentActivity() : activity | ||
577 | ); | 578 | ); | ||
578 | 579 | | |||
579 | const auto clientFilter = | 580 | const auto clientFilter = | ||
580 | client == ANY_AGENT_TAG ? " 1 " : | 581 | client == ANY_AGENT_TAG ? " 1 " : | ||
581 | QStringLiteral(" initiatingAgent = '%1' ").arg(client); | 582 | QStringLiteral(" initiatingAgent = '%1' ").arg(client); | ||
582 | 583 | | |||
583 | auto removeEventsQuery = resourcesDatabase().createQuery(); | 584 | auto removeEventsQuery = resourcesDatabase()->createQuery(); | ||
584 | removeEventsQuery.prepare( | 585 | removeEventsQuery.prepare( | ||
585 | "DELETE FROM ResourceEvent " | 586 | "DELETE FROM ResourceEvent " | ||
586 | "WHERE " | 587 | "WHERE " | ||
587 | + activityFilter + " AND " | 588 | + activityFilter + " AND " | ||
588 | + clientFilter + " AND " | 589 | + clientFilter + " AND " | ||
589 | + "targettedResource LIKE :targettedResource ESCAPE '\\'" | 590 | + "targettedResource LIKE :targettedResource ESCAPE '\\'" | ||
590 | ); | 591 | ); | ||
591 | 592 | | |||
592 | auto removeScoreCachesQuery = resourcesDatabase().createQuery(); | 593 | auto removeScoreCachesQuery = resourcesDatabase()->createQuery(); | ||
593 | removeScoreCachesQuery.prepare( | 594 | removeScoreCachesQuery.prepare( | ||
594 | "DELETE FROM ResourceScoreCache " | 595 | "DELETE FROM ResourceScoreCache " | ||
595 | "WHERE " | 596 | "WHERE " | ||
596 | + activityFilter + " AND " | 597 | + activityFilter + " AND " | ||
597 | + clientFilter + " AND " | 598 | + clientFilter + " AND " | ||
598 | + "targettedResource LIKE :targettedResource ESCAPE '\\'" | 599 | + "targettedResource LIKE :targettedResource ESCAPE '\\'" | ||
599 | ); | 600 | ); | ||
600 | 601 | | |||
▲ Show 20 Lines • Show All 123 Lines • Show Last 20 Lines |