Allow suffix on onelinerz DB name

This commit is contained in:
Bryan Ashby 2020-12-07 19:53:49 -07:00
parent 6ad33c2de7
commit b579d966b6
No known key found for this signature in database
GPG Key ID: B49EB437951D2542
3 changed files with 6 additions and 3 deletions

View File

@ -14,6 +14,7 @@ This document attempts to track **major** changes and additions in ENiGMA½. For
* File base search has had an improvement to search term handling. * File base search has had an improvement to search term handling.
* `./oputil user group -group` to now accepts `~group` removing the need for special handling of the "-" character. #331 * `./oputil user group -group` to now accepts `~group` removing the need for special handling of the "-" character. #331
* A fix has been made to clean up old `file.db` entries when a file is removed. Previously stale records could be left or even recycled into new entries. Please see [UPGRADE.md](UPGRADE.md) for details on applying this fix (look for `tables_update_2020-11-29.sql`). * A fix has been made to clean up old `file.db` entries when a file is removed. Previously stale records could be left or even recycled into new entries. Please see [UPGRADE.md](UPGRADE.md) for details on applying this fix (look for `tables_update_2020-11-29.sql`).
* The [./docs/modding/onelinerz.md](onelinerz) module can have `dbSuffix` set in it's `config` block to specify a separate DB file. For example to use as a requests list.
## 0.0.11-beta ## 0.0.11-beta
* Upgraded from `alpha` to `beta` -- The software is far along and mature enough at this point! * Upgraded from `alpha` to `beta` -- The software is far along and mature enough at this point!

View File

@ -135,7 +135,7 @@ exports.getModule = class OnelinerzModule extends MenuModule {
self.db.each( self.db.each(
`SELECT * `SELECT *
FROM ( FROM (
SELECT * SELECT *
FROM onelinerz FROM onelinerz
ORDER BY timestamp DESC ORDER BY timestamp DESC
LIMIT ${limit} LIMIT ${limit}
@ -248,8 +248,9 @@ exports.getModule = class OnelinerzModule extends MenuModule {
async.series( async.series(
[ [
function openDatabase(callback) { function openDatabase(callback) {
const dbSuffix = self.menuConfig.config.dbSuffix;
self.db = getTransactionDatabase(new sqlite3.Database( self.db = getTransactionDatabase(new sqlite3.Database(
getModDatabasePath(exports.moduleInfo), getModDatabasePath(exports.moduleInfo, dbSuffix),
err => { err => {
return callback(err); return callback(err);
} }
@ -260,7 +261,7 @@ exports.getModule = class OnelinerzModule extends MenuModule {
`CREATE TABLE IF NOT EXISTS onelinerz ( `CREATE TABLE IF NOT EXISTS onelinerz (
id INTEGER PRIMARY KEY, id INTEGER PRIMARY KEY,
user_id INTEGER_NOT NULL, user_id INTEGER_NOT NULL,
user_name VARCHAR NOT NULL, user_name VARCHAR NOT NULL,
oneliner VARCHAR NOT NULL, oneliner VARCHAR NOT NULL,
timestamp DATETIME NOT NULL timestamp DATETIME NOT NULL
);` );`

View File

@ -9,6 +9,7 @@ The built in `onelinerz` module provides a retro onelinerz system.
### Config Block ### Config Block
Available `config` block entries: Available `config` block entries:
* `dateTimeFormat`: [moment.js](https://momentjs.com) style format. Defaults to current theme → system `short` date format. * `dateTimeFormat`: [moment.js](https://momentjs.com) style format. Defaults to current theme → system `short` date format.
* `dbSuffix`: Provide a suffix that will be appended to the DB name to use onelinerz for more than one purpose (separate lists).
### Theming ### Theming
The following `itemFormat` object is provided to MCI 1 (ie: `%VM1`): The following `itemFormat` object is provided to MCI 1 (ie: `%VM1`):