Warning: session_start(): open(/var/lib/php/sessions/sess_ed4fne9ei3bqk20ou9r1vactb4, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
sclass SearchResult {
S snippetID;
S title;
int occurrences;
sS _fieldOrder = "snippetID title occurrences";
}
cmodule FullTextSnippetSearch > DynTableWithInput2 {
switchable int maxResults = 1000;
transient S status;
JComponent mainComponent() {
ret northAndCenterWithMargin(dm_rightAlignedLabel status(), super.mainComponent());
}
start {
dontPersist();
}
void calc {
S query = upper(input);
S mod = dm_require("#1028945/CacheAllSnippets");
SS data = cast dm_rcall getData(mod);
SS titles = cast dm_rcall getTitles(mod);
new L out;
if (nempty(query)) {
time "Full-Text Search" {
fOr ping (S snippetID, text : data) {
S title = titles.get(snippetID);
int n =
countOccurrences(title, query)
+ countOccurrences(text, query);
if (n > 0) {
new SearchResult r;
r.snippetID = snippetID;
r.title = title;
r.occurrences = n;
out.add(r);
if (l(out) >= maxResults) break;
}
}
}
}
sortInPlaceByCalculatedFieldDesc(out, r -> r.occurrences);
setField(status := "Found " + addPlusToCount(maxResults, l(out), nSnippets(out) + " in " + lastTiming() + " ms");
setList(out);
}
}