MCPcopy Create free account
hub / github.com/baumgarr/nixnote2 / countNotebooks

Method countNotebooks

threads/counterrunner.cpp:71–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69
70
71void CounterRunner::countNotebooks() {
72 if (global.countBehavior == Global::CountNone)
73 return;
74
75 QLOG_TRACE_IN();
76 if (!init)
77 initialize();
78
79 // First get every possible notebook
80 NotebookTable nTable(db);
81 QList<qint32> lids;
82 nTable.getAll(lids);
83
84 // Next, get the totals of everything possible
85 QHash<qint32, qint32> allNotebooks;
86 for (int i=0; i<lids.size(); i++) {
87 allNotebooks.insert(lids.at(i), 0);
88 }
89
90 NSqlQuery query(db);
91 query.exec(" select data, count(data) from datastore where key=5011 and lid not in (select lid from datastore where data=0 and key=5010) group by data;");
92 while (query.next()) {
93 qint32 lid = query.value(0).toInt();
94 qint32 total = query.value(1).toInt();
95 allNotebooks[lid] = total;
96 }
97
98 query.exec("select notebooklid, count(notebooklid) from notetable where lid in (select lid from filter) and lid not in (select lid from datastore where data=0 and key=5010) group by notebooklid;");
99
100 while(query.next()) {
101 qint32 lid = query.value(0).toInt();
102 emit notebookTotals(lid, query.value(1).toInt(), allNotebooks[lid]);
103 lids.removeAll(lid);
104 }
105
106 // The ones that are left have a zero count
107 for (int i=0; i<lids.size(); i++)
108 emit(notebookTotals(lids[i], 0, allNotebooks[lids[i]]));
109
110 emit(notebookTotals(-1, -1, -1));
111 QLOG_TRACE_OUT();
112}
113
114
115void CounterRunner::countTags() {

Callers 1

countAllMethod · 0.95

Calls 4

insertMethod · 0.80
valueMethod · 0.80
getAllMethod · 0.45
execMethod · 0.45

Tested by

no test coverage detected