mirror of https://github.com/velour/catbase.git
Add TODO, small fix to factoid web interface
This commit is contained in:
parent
c91f4a8535
commit
56c6d84813
|
@ -0,0 +1,24 @@
|
||||||
|
# TODO
|
||||||
|
|
||||||
|
## Preface
|
||||||
|
|
||||||
|
This bot was written a long time back in the spare time of a busy person. The code is often ugly and probably not idiomatic. Updating that to a modern testable codebase may be obnoxious, but every complete rewrite tends to end in stagnation, and this codebase does seem to work for the most part. You will not hurt the original author's feelings by fixing what's bad and refactoring what's good.
|
||||||
|
|
||||||
|
## Never going to get done:
|
||||||
|
|
||||||
|
* Migrate SQL to something that can marshal into structs
|
||||||
|
* https://github.com/jmoiron/sqlx
|
||||||
|
* Fix plugin structure to not have so many exported fields. None of them need to be exporting the bot reference, for example.
|
||||||
|
* Perhaps refactor a bit so stuff can be tested
|
||||||
|
* Fix names in factoid to actually match the bucket terminology. Some things are migrated, but not everything. There should be no instances of:
|
||||||
|
* Trigger
|
||||||
|
* Action
|
||||||
|
* FullText
|
||||||
|
* Operator
|
||||||
|
* Figure out something better for time?
|
||||||
|
* SQLite has a datetime, but the driver can't seem to handle null
|
||||||
|
* SQLite sometimes returns a different date string, which appers to be what the driver is trying to translate from/to
|
||||||
|
* Implement factoid aliasing
|
||||||
|
* Implement an object system for the give/take commands
|
||||||
|
* Create some kind of web reference page
|
||||||
|
* Enter all of this into GitHub tickets
|
|
@ -38,6 +38,9 @@ type Bot struct {
|
||||||
Config *config.Config
|
Config *config.Config
|
||||||
|
|
||||||
// SQL DB
|
// SQL DB
|
||||||
|
// TODO: I think it'd be nice to use https://github.com/jmoiron/sqlx so that
|
||||||
|
// the select/update/etc statements could be simplified with struct
|
||||||
|
// marshalling.
|
||||||
DB *sql.DB
|
DB *sql.DB
|
||||||
DBVersion int64
|
DBVersion int64
|
||||||
|
|
||||||
|
|
|
@ -654,9 +654,10 @@ func (p *FactoidPlugin) serveQuery(w http.ResponseWriter, r *http.Request) {
|
||||||
"linkify": linkify,
|
"linkify": linkify,
|
||||||
}
|
}
|
||||||
if e := r.FormValue("entry"); e != "" {
|
if e := r.FormValue("entry"); e != "" {
|
||||||
var entries []factoid
|
entries, err := getFacts(p.db, e)
|
||||||
// TODO: Fix the web interface with text search?
|
if err != nil {
|
||||||
// p.Coll.Find(bson.M{"trigger": bson.M{"$regex": strings.ToLower(e)}}).All(&entries)
|
log.Println("Web error searching: ", err)
|
||||||
|
}
|
||||||
context["Count"] = fmt.Sprintf("%d", len(entries))
|
context["Count"] = fmt.Sprintf("%d", len(entries))
|
||||||
context["Entries"] = entries
|
context["Entries"] = entries
|
||||||
context["Search"] = e
|
context["Search"] = e
|
||||||
|
|
Loading…
Reference in New Issue