diff -uNr a/logotron/MANIFEST.TXT b/logotron/MANIFEST.TXT --- a/logotron/MANIFEST.TXT de2532e106e3a761c231f92427b6c099f7e5d1b6f01759ba443a28682289642707a59dd738833cda23d849ca36784ec449bed22bab70ab712be4f24da2b9b6a7 +++ b/logotron/MANIFEST.TXT 655b5de46011cf8638efc7ec9a57cc5ba577d3198567c657edb4f18d86bb88a668187573c97dec98e3bbac48f0ab588d27d2067e3d39b78c7ef0294d6d0ee9fb @@ -22,3 +22,4 @@ 684804 frontend_updates billymg "Changes to HTML/CSS to allow for easier theming. Added config knobs for custom log root and CSS file." 684819 add_bitdash_theme billymg "Add dark theme used on http://logs.bitdash.io" 689331 lose_fleanode asciilifeform "Remove all Freenodeisms." +696566 archived_chans asciilifeform "Allow marking a chan as 'archived' to improve DB performance." diff -uNr a/logotron/nsabot.conf b/logotron/nsabot.conf --- a/logotron/nsabot.conf 7e1f575d5950f04bb47b266aef27f06152baa34a2d688f1c8329c35bc19bc11fe325b5468faa646cf338e420a154ba57adcf47486b771d7ca18246f26d507a76 +++ b/logotron/nsabot.conf b2117eaa3fbedff592b133635a84997b236d781936c9e8473d771ad67ab4e20a4a36062c9449b4ac0ee0fc7cd4c2bced405105a250378bd3a6a5658de05c3a30 @@ -4,14 +4,17 @@ log = nsabot.log [irc] -servers = irc.freenode.net +servers = irc.dulap.xyz port = 6667 # Bot's nick (change to yours, as with all knobs) nick = snsabot -# All chans for both www end and bot, go here: -chans = asciilifeform-test, asciilifeform-test-2 +# Chans CURRENTLY logged by the bot, go here: +chans = asciilifeform + +# Archived chans (i.e. no longer logged by bot, but still displayed in WWW logger) +oldchans = therealbitcoin, billymg, trinque, agriculturalsupremacy, ossasepia, spyked, pizarro, trilema, alethepedia # IRC nick PW pass = YOURPW diff -uNr a/logotron/reader.py b/logotron/reader.py --- a/logotron/reader.py f79f7c4c71ad9151c80feed185acbf54b531eaafe10db7a1a3a1e559176ea8c821114ad03df77cebcd4af83ee3e64c2adb6a2eec52b8e152dc8a0926b37f59b9 +++ b/logotron/reader.py c249c7a987199fd5e0356b13c36401654b4df837e238c8c91c10c3a988b91ba6a19c908f7e33298e559ef40b058e6c67ec6e9da4bb8539c8153aa6cbf17bbabc @@ -38,6 +38,7 @@ # IRCism: Nick = cfg.get("irc", "nick") Channels = [x.strip() for x in cfg.get("irc", "chans").split(',')] + OldChans = [x.strip() for x in cfg.get("irc", "oldchans").split(',')] Bots = [x.strip() for x in cfg.get("logotron", "bots").split(',')] Bots.append(Nick) # Add our own bot to the bot list # DBism: @@ -66,6 +67,10 @@ ### Knobs not made into config yet ### Default_Chan = Channels[0] Min_Query_Length = 3 +All_Chans = Channels + OldChans + +# Cache of last-activity times of the archived chans +oldchan_last_active = {} ## Format for Date in Log Lines Date_Short_Format = "%Y-%m-%d" @@ -136,17 +141,34 @@ l['t'].strftime(Date_Short_Format), l['idx']) +# Determine, via DB, when given chan was last active +def last_active(chan): + return query_db( + '''select t, idx from loglines where chan=%s + and idx = (select max(idx) from loglines where chan=%s) ;''', + [chan, chan], one=True) + +# Cache the last-activity times of the archived chans +@app.before_first_request +def init_oldchan_activity_cache(): + for chan in OldChans: + oldchan_last_active[chan] = last_active(chan) + +# Return last activity time in given channel (if archived chan -- from cache) +def get_last_activity(chan): + if chan in OldChans: + return oldchan_last_active[chan] + else: + return last_active(chan) + def gen_chanlist(selected_chan, show_all_chans=False): # Get current time now = datetime.now() # Data for channel display : chan_list = [] chan_idx = 0 - for chan in Channels: - last_time = query_db( - '''select t, idx from loglines where chan=%s - and idx = (select max(idx) from loglines where chan=%s) ;''', - [chan, chan], one=True) + for chan in All_Chans: + last_time = get_last_activity(chan) last_time_txt = "" last_time_url = "" @@ -307,7 +329,7 @@ @app.route('/rnd/') def rnd(chan): # Handle rubbish chan: - if chan not in Channels: + if chan not in All_Chans: return redirect(url_for('log')) rnd_line = query_db( @@ -323,7 +345,7 @@ @app.route('%s' % App_Root, defaults={'chan': Default_Chan, 'date': None}) def log(chan, date): # Handle rubbish chan: - if chan not in Channels: + if chan not in All_Chans: return redirect(url_for('log')) # Get possible selection start and end @@ -417,7 +439,7 @@ @app.route('/ilog//') def ilog(chan, idx): # Handle rubbish chan: - if chan not in Channels: + if chan not in All_Chans: return redirect(url_for('log')) # Attempt to locate given chan/idx: @@ -441,7 +463,7 @@ res = "" # Handle rubbish chan: - if chan not in Channels: + if chan not in All_Chans: return Response("EGGOG: No such Channel!", mimetype='text/plain') # Get start and end indices: @@ -510,13 +532,13 @@ if chan == 'all': # search in all logged channels - chans = Channels + chans = All_Chans legend = "all logged channels" showchan = True show_all = 1 else: # Handle possible rubbish chan: - if chan not in Channels: + if chan not in All_Chans: return redirect(url_for('log')) else: # search in selected channel only @@ -612,4 +634,5 @@ ## App Mode if __name__ == '__main__': + ##init_oldchan_activity_cache() app.run(threaded=True, port=WWW_Port) diff -uNr a/logotron/release_notes.txt b/logotron/release_notes.txt --- a/logotron/release_notes.txt fc613fc6b9264924b46517b361dbfe9d1996770f9b942accef9dd9e30f755bb40f5b0ee7515c98e7acc6bf1dfdc0e30ad94b17e135cdcd2b7d9670d69508abf6 +++ b/logotron/release_notes.txt 8ef7c43d3def3d30a81188b7f2167acb5a7dcaada92c800dbc93fa554c985f059728b90cdefb70e5290a5e5673556ed04db66e0f9570599e984765ac4e0e1282 @@ -1,4 +1,12 @@ ###################### +2021 Aug 19 Update #2: +###################### +----------------------------------------------------------------------------------- +696566 archived_chans asciilifeform "Allow marking a chan as 'archived' to improve DB performance." +----------------------------------------------------------------------------------- +(1) Added 'oldchans' knob in config; this represents chans no longer active from the bot's POV, but nonetheless displayed in WWW logger. This allows to improve page load time by avoiding the per-chan DB access penalty for chans known to be inactive. + +###################### 2021 Aug 19 Update #1: ###################### -----------------------------------------------------------------------------------