Skip to content

Commit

Permalink
Merge pull request #73 from quakenet/retropc-patch-2
Browse files Browse the repository at this point in the history
A4STATS: remove E style escapes and switch to createtable for indices
  • Loading branch information
retropc committed May 31, 2018
2 parents d5fe820 + 7004a17 commit ee1fce9
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions a4stats/a4stats_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#define CLEANUP_INACTIVE_DAYS 30 /* disable channels where nothing happened for this many days */
#define CLEANUP_DELETE_DAYS 5 /* delete data for channels that have been disabled for this many days */

#define A4STATS_DB_TOLOWER(x) "translate(lower(" x "), E'[]\\\\~', '{}|^')"
#define A4STATS_DB_TOLOWER(x) "translate(lower(" x "), '[]\\~', '{}|^')"
#define A4STATS_DB_EQ_NOCASE(x, y) A4STATS_DB_TOLOWER(x) " = " A4STATS_DB_TOLOWER(y)

MODULE_VERSION("");
Expand All @@ -43,14 +43,14 @@ static int a4stats_connectdb(void) {
"CREATE TABLE ? (channelid INT, kicker VARCHAR(128), kickerid INT, victim VARCHAR(128), victimid INT, timestamp INT, reason VARCHAR(256),"
"FOREIGN KEY (channelid) REFERENCES ? (id) ON DELETE CASCADE)", "TT", "kicks", "channels");

a4statsdb->squery(a4statsdb, "CREATE INDEX kicks_channelid_index ON ? (channelid)", "T", "kicks");
a4statsdb->squery(a4statsdb, "CREATE INDEX kicks_timestamp_index ON ? (timestamp)", "T", "kicks");
a4statsdb->createtable(a4statsdb, NULL, NULL, "CREATE INDEX kicks_channelid_index ON ? (channelid)", "T", "kicks");
a4statsdb->createtable(a4statsdb, NULL, NULL, "CREATE INDEX kicks_timestamp_index ON ? (timestamp)", "T", "kicks");

a4statsdb->createtable(a4statsdb, NULL, NULL,
"CREATE TABLE ? (channelid INT, setby VARCHAR(128), setbyid INT, timestamp INT, topic VARCHAR(512),"
"FOREIGN KEY (channelid) REFERENCES ? (id) ON DELETE CASCADE)", "TT", "topics", "channels");

a4statsdb->squery(a4statsdb, "CREATE INDEX topics_channelid_index ON ? (channelid)", "T", "topics");
a4statsdb->createtable(a4statsdb, NULL, NULL, "CREATE INDEX topics_channelid_index ON ? (channelid)", "T", "topics");

a4statsdb->createtable(a4statsdb, NULL, NULL,
"CREATE TABLE ? (channelid INT, account VARCHAR(128), accountid INT, seen INT DEFAULT 0, rating INT DEFAULT 0, lines INT DEFAULT 0, chars INT DEFAULT 0, words INT DEFAULT 0, "
Expand All @@ -62,18 +62,18 @@ static int a4stats_connectdb(void) {
"slaps INT DEFAULT 0, slapped INT DEFAULT 0, highlights INT DEFAULT 0, kicks INT DEFAULT 0, kicked INT DEFAULT 0, ops INT DEFAULT 0, deops INT DEFAULT 0, actions INT DEFAULT 0, skitzo INT DEFAULT 0, foul INT DEFAULT 0, "
"firstseen INT DEFAULT 0, curnick VARCHAR(16), FOREIGN KEY (channelid) REFERENCES ? (id) ON DELETE CASCADE)", "TT", "users", "channels");

a4statsdb->squery(a4statsdb, "CREATE INDEX users_account_index ON ? (account)", "T", "users");
a4statsdb->squery(a4statsdb, "CREATE INDEX users_accountid_index ON ? (accountid)", "T", "users");
a4statsdb->squery(a4statsdb, "CREATE INDEX users_channelid_index ON ? (channelid)", "T", "users");
a4statsdb->squery(a4statsdb, "CREATE UNIQUE INDEX users_channelid_account_accountid_index ON ? (channelid, account, accountid)", "T", "users");
a4statsdb->squery(a4statsdb, "CREATE INDEX users_channelid_lines_index ON ? (channelid, lines)", "T", "users");
a4statsdb->createtable(a4statsdb, NULL, NULL, "CREATE INDEX users_account_index ON ? (account)", "T", "users");
a4statsdb->createtable(a4statsdb, NULL, NULL, "CREATE INDEX users_accountid_index ON ? (accountid)", "T", "users");
a4statsdb->createtable(a4statsdb, NULL, NULL, "CREATE INDEX users_channelid_index ON ? (channelid)", "T", "users");
a4statsdb->createtable(a4statsdb, NULL, NULL, "CREATE UNIQUE INDEX users_channelid_account_accountid_index ON ? (channelid, account, accountid)", "T", "users");
a4statsdb->createtable(a4statsdb, NULL, NULL, "CREATE INDEX users_channelid_lines_index ON ? (channelid, lines)", "T", "users");

a4statsdb->createtable(a4statsdb, NULL, NULL,
"CREATE TABLE ? (channelid INT, first VARCHAR(128), firstid INT, second VARCHAR(128), secondid INT, seen INT, score INT DEFAULT 1,"
"FOREIGN KEY (channelid) REFERENCES ? (id) ON DELETE CASCADE)", "TT", "relations", "channels");

a4statsdb->squery(a4statsdb, "CREATE INDEX relations_channelid_index ON ? (channelid)", "T", "relations");
a4statsdb->squery(a4statsdb, "CREATE INDEX relations_score_index ON ? (score)", "T", "relations");
a4statsdb->createtable(a4statsdb, NULL, NULL, "CREATE INDEX relations_channelid_index ON ? (channelid)", "T", "relations");
a4statsdb->createtable(a4statsdb, NULL, NULL, "CREATE INDEX relations_score_index ON ? (score)", "T", "relations");


return 1;
Expand Down

0 comments on commit ee1fce9

Please sign in to comment.