avoid loading as many alerts outside of the bounding box
This commit is contained in:
parent
fc6544d620
commit
bc16b724c2
|
@ -394,13 +394,13 @@ func peekMatch(cur int, phrase string, runes []rune) bool {
|
|||
}
|
||||
|
||||
// ! Not concurrency safe
|
||||
func AddHashLinkType(prefix string, handler func(*strings.Builder, string, *int)) {
|
||||
func AddHashLinkType(prefix string, h func(*strings.Builder, string, *int)) {
|
||||
// There can only be one hash link type starting with a specific character at the moment
|
||||
hashType := hashLinkTypes[prefix[0]]
|
||||
if hashType != "" {
|
||||
return
|
||||
}
|
||||
hashLinkMap[prefix] = handler
|
||||
hashLinkMap[prefix] = h
|
||||
hashLinkTypes[prefix[0]] = prefix
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ func NewSQLReplyStore(acc *qgen.Accumulator, cache ReplyCache) (*SQLReplyStore,
|
|||
return &SQLReplyStore{
|
||||
cache: cache,
|
||||
get: acc.Select(re).Columns("tid, content, createdBy, createdAt, lastEdit, lastEditBy, ip, likeCount, attachCount, actionType").Where("rid=?").Prepare(),
|
||||
getAll: acc.Select(re).Columns("rid,tid, content, createdBy, createdAt, lastEdit, lastEditBy, ip, likeCount, attachCount, actionType").Prepare(),
|
||||
getAll: acc.Select(re).Columns("rid,tid,content,createdBy,createdAt,lastEdit,lastEditBy,ip,likeCount,attachCount,actionType").Prepare(),
|
||||
exists: acc.Exists(re, "rid").Prepare(),
|
||||
create: acc.Insert(re).Columns("tid, content, parsed_content, createdAt, lastUpdated, ip, words, createdBy").Fields("?,?,?,UTC_TIMESTAMP(),UTC_TIMESTAMP(),?,?,?").Prepare(),
|
||||
count: acc.Count(re).Prepare(),
|
||||
|
|
8
mssql.go
8
mssql.go
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
*
|
||||
* Gosora MSSQL Interface
|
||||
* Copyright Azareal 2016 - 2019
|
||||
* Copyright Azareal 2016 - 2020
|
||||
*
|
||||
*/
|
||||
package main
|
||||
|
@ -78,6 +78,12 @@ func initMSSQL() (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
log.Print("Preparing getActivityFeedByWatcher statement.")
|
||||
stmts.getActivityFeedByWatcherStmt, err = db.Prepare("SELECT activity_stream_matches.asid, activity_stream.actor, activity_stream.targetUser, activity_stream.event, activity_stream.elementType, activity_stream.elementID, activity_stream.createdAt FROM [activity_stream_matches] INNER JOIN [activity_stream] ON activity_stream_matches.asid = activity_stream.asid AND activity_stream_matches.watcher != activity_stream.actor WHERE [watcher] = ? ORDER BY activity_stream.asid DESC OFFSET 0 ROWS FETCH NEXT ? ROWS ONLY")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Print("Preparing getActivityCountByWatcher statement.")
|
||||
stmts.getActivityCountByWatcherStmt, err = db.Prepare("SELECT count(*) FROM [activity_stream_matches] INNER JOIN [activity_stream] ON activity_stream_matches.asid = activity_stream.asid AND activity_stream_matches.watcher != activity_stream.actor WHERE [watcher] = ?")
|
||||
if err != nil {
|
||||
|
|
14
mysql.go
14
mysql.go
|
@ -53,12 +53,24 @@ func initMySQL() (err error) {
|
|||
}
|
||||
|
||||
// TODO: Is there a less noisy way of doing this for tests?
|
||||
log.Print("Preparing getActivityFeedByWatcher statement.")
|
||||
/*log.Print("Preparing getActivityFeedByWatcher statement.")
|
||||
stmts.getActivityFeedByWatcher, err = db.Prepare("SELECT activity_stream_matches.asid, activity_stream.actor, activity_stream.targetUser, activity_stream.event, activity_stream.elementType, activity_stream.elementID, activity_stream.createdAt FROM `activity_stream_matches` INNER JOIN `activity_stream` ON activity_stream_matches.asid = activity_stream.asid AND activity_stream_matches.watcher != activity_stream.actor WHERE `watcher` = ? ORDER BY activity_stream.asid DESC LIMIT 16")
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
}*/
|
||||
|
||||
log.Print("Preparing getActivityFeedByWatcher statement.")
|
||||
stmts.getActivityFeedByWatcher, err = db.Prepare("SELECT activity_stream_matches.asid, activity_stream.actor, activity_stream.targetUser, activity_stream.event, activity_stream.elementType, activity_stream.elementID, activity_stream.createdAt FROM `activity_stream_matches` INNER JOIN `activity_stream` ON activity_stream_matches.asid = activity_stream.asid AND activity_stream_matches.watcher != activity_stream.actor WHERE `watcher` = ? ORDER BY activity_stream.asid DESC LIMIT ?")
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
|
||||
/*log.Print("Preparing getActivityFeedByWatcherAfter statement.")
|
||||
stmts.getActivityFeedByWatcherAfter, err = db.Prepare("SELECT activity_stream_matches.asid, activity_stream.actor, activity_stream.targetUser, activity_stream.event, activity_stream.elementType, activity_stream.elementID, activity_stream.createdAt FROM `activity_stream_matches` INNER JOIN `activity_stream` ON activity_stream_matches.asid = activity_stream.asid AND activity_stream_matches.watcher != activity_stream.actor WHERE `watcher` = ? AND createdAt => ? ORDER BY activity_stream.asid DESC LIMIT ?")
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
}*/
|
||||
|
||||
log.Print("Preparing getActivityCountByWatcher statement.")
|
||||
stmts.getActivityCountByWatcher, err = db.Prepare("SELECT count(*) FROM `activity_stream_matches` INNER JOIN `activity_stream` ON activity_stream_matches.asid = activity_stream.asid AND activity_stream_matches.watcher != activity_stream.actor WHERE `watcher` = ?")
|
||||
if err != nil {
|
||||
|
|
2
pgsql.go
2
pgsql.go
|
@ -1,6 +1,6 @@
|
|||
// +build pgsql
|
||||
|
||||
/* Copyright Azareal 2016 - 2019 */
|
||||
/* Copyright Azareal 2016 - 2020 */
|
||||
/* Super experimental and incomplete. DON'T USE IT YET! */
|
||||
package main
|
||||
|
||||
|
|
|
@ -124,13 +124,13 @@ function updateAlertList(menuAlerts) {
|
|||
}
|
||||
|
||||
function setAlertError(menuAlerts,msg) {
|
||||
let alertListNode = menuAlerts.getElementsByClassName("alertList")[0];
|
||||
alertListNode.innerHTML = "<div class='alertItem'>"+msg+"</div>";
|
||||
let n = menuAlerts.getElementsByClassName("alertList")[0];
|
||||
n.innerHTML = "<div class='alertItem'>"+msg+"</div>";
|
||||
}
|
||||
|
||||
var alertsInitted = false;
|
||||
var lastTc = 0;
|
||||
function loadAlerts(menuAlerts, eTc=false) {
|
||||
function loadAlerts(menuAlerts,eTc=false) {
|
||||
if(!alertsInitted) return;
|
||||
let tc = "";
|
||||
if(eTc && lastTc != 0) tc = "&t=" + lastTc + "&c=" + alertCount;
|
||||
|
@ -787,7 +787,7 @@ function mainInit(){
|
|||
$(".unix_to_24_hour_time").each(function(){
|
||||
let unixTime = this.innerText;
|
||||
let date = new Date(unixTime*1000);
|
||||
console.log("date", date);
|
||||
console.log("date",date);
|
||||
let minutes = "0" + date.getMinutes();
|
||||
let formattedTime = date.getHours() + ":" + minutes.substr(-2);
|
||||
console.log("formattedTime",formattedTime);
|
||||
|
@ -814,8 +814,8 @@ function mainInit(){
|
|||
});
|
||||
|
||||
this.onkeyup = function(ev) {
|
||||
if(ev.which == 37) this.querySelectorAll("#prevFloat a")[0].click();
|
||||
if(ev.which == 39) this.querySelectorAll("#nextFloat a")[0].click();
|
||||
if(ev.which==37) this.querySelectorAll("#prevFloat a")[0].click();
|
||||
if(ev.which==39) this.querySelectorAll("#nextFloat a")[0].click();
|
||||
};
|
||||
|
||||
function asyncGetSheet(src) {
|
||||
|
|
|
@ -119,7 +119,7 @@ func routeAPI(w http.ResponseWriter, r *http.Request, user *c.User) c.RouteError
|
|||
var topCreatedAt int64
|
||||
|
||||
if count != 0 {
|
||||
rows, err := stmts.getActivityFeedByWatcher.Query(user.ID)
|
||||
rows, err := stmts.getActivityFeedByWatcher.Query(user.ID, 12)
|
||||
if err != nil {
|
||||
return c.InternalErrorJS(err, w, r)
|
||||
}
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
<form action="/accounts/login/submit/" method="post">
|
||||
<div class="formrow login_name_row">
|
||||
<div class="formitem formlabel"><a id="login_name_label">{{lang "login_account_name"}}</a></div>
|
||||
<div class="formitem"><input name="username" type="text" placeholder="{{lang "login_account_name"}}" aria-labelledby="login_name_label" required></div>
|
||||
<div class="formitem"><input name="username"type="text"placeholder="{{lang "login_account_name"}}" aria-labelledby="login_name_label" required></div>
|
||||
</div>
|
||||
<div class="formrow login_password_row">
|
||||
<div class="formitem formlabel"><a id="login_password_label">{{lang "login_account_password"}}</a></div>
|
||||
<div class="formitem"><input name="password" type="password" autocomplete="current-password" placeholder="*****" aria-labelledby="login_password_label" required></div>
|
||||
<div class="formitem"><input name="password"type="password"autocomplete="current-password"placeholder="*****"aria-labelledby="login_password_label" required></div>
|
||||
</div>
|
||||
<div class="formrow login_button_row form_button_row">
|
||||
<div class="formitem"><button name="login-button" class="formbutton">{{lang "login_submit_button"}}</button></div>
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
</div>
|
||||
{{else}}<div class="formrow">
|
||||
<div class="formitem formlabel"><a>{{lang "panel_setting_value"}}</a></div>
|
||||
<div class="formitem"><input name="value" type="text" value="{{.Setting.Content}}"></div>
|
||||
<div class="formitem"><input name="value"type="text"value="{{.Setting.Content}}"></div>
|
||||
</div>{{end}}
|
||||
<div class="formrow form_button_row">
|
||||
<div class="formitem"><button name="panel-button" class="formbutton">{{lang "panel_setting_update_button"}}</button></div>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
{{if lt .UserCount 30}}
|
||||
{{range .Users}}<div class="rowitem"style="background-image:url('{{.Avatar}}');">
|
||||
<img src="{{.Avatar}}"class="bgsub"alt="Avatar"aria-hidden="true">
|
||||
<a class="rowTitle" href="{{.Link}}">{{.Name}}</a>
|
||||
<a class="rowTitle"href="{{.Link}}">{{.Name}}</a>
|
||||
</div>
|
||||
{{else}}<div class="rowitem rowmsg">{{lang "widget.online_none_online"}}</div>{{end}}
|
||||
{{else}}<div class="rowitem rowmsg">{{langf "widget.online_some_online" .UserCount}}</div>{{end}}
|
||||
|
|
Loading…
Reference in New Issue