updated theme branch, added postgresql support
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
23afca0244
commit
bf1a033725
@ -40,39 +40,57 @@ func (config *Config) GetConfig() error {
|
||||
config.Cron = qrzsection.Key("cron").MustString("@every 1h")
|
||||
|
||||
config.DbSchema = fmt.Sprintf(`
|
||||
CREATE TABLE IF NOT EXISTS %s
|
||||
(
|
||||
id int(8) NOT NULL AUTO_INCREMENT,
|
||||
qrz varchar(25) NOT NULL,
|
||||
name varchar(25) DEFAULT NULL,
|
||||
address varchar(50) DEFAULT NULL,
|
||||
city varchar(50) DEFAULT NULL,
|
||||
zipcode varchar(5) DEFAULT NULL,
|
||||
dept varchar(50) DEFAULT NULL,
|
||||
country varchar(25) DEFAULT NULL,
|
||||
dmrid varchar(25) DEFAULT NULL,
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY qrz (qrz,name,city,dept) USING BTREE,
|
||||
KEY test (country),
|
||||
FULLTEXT KEY city (city),
|
||||
FULLTEXT KEY dept (dept)
|
||||
)
|
||||
ENGINE=InnoDB DEFAULT CHARSET=utf8;`,
|
||||
CREATE TABLE IF NOT EXISTS %[1]s (
|
||||
id serial NOT NULL PRIMARY KEY,
|
||||
qrz varchar(25) NOT NULL,
|
||||
name varchar(25) DEFAULT NULL,
|
||||
address varchar(50) DEFAULT NULL,
|
||||
city varchar(50) DEFAULT NULL,
|
||||
zipcode varchar(5) DEFAULT NULL,
|
||||
dept varchar(50) DEFAULT NULL,
|
||||
country varchar(25) DEFAULT NULL,
|
||||
dmrid varchar(25) DEFAULT NULL,
|
||||
fts tsvector NULL,
|
||||
CONSTRAINT qrz_unique UNIQUE(qrz, name, city, dept, country)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS fts_idx ON %[1]s (fts);
|
||||
|
||||
CREATE OR REPLACE FUNCTION updateFTS() RETURNS trigger AS $fts_trigger$
|
||||
BEGIN
|
||||
IF pg_trigger_depth() <> 1 THEN
|
||||
RETURN NEW;
|
||||
END IF;
|
||||
UPDATE %[1]s SET fts = to_tsvector(concat_ws(' ', qrz, name, city, dept, country)) WHERE id = NEW.id;
|
||||
RETURN NEW;
|
||||
END;
|
||||
$fts_trigger$ LANGUAGE plpgsql;
|
||||
|
||||
DROP TRIGGER IF EXISTS fts_trigger ON %[1]s;
|
||||
|
||||
CREATE TRIGGER fts_trigger
|
||||
AFTER INSERT ON %[1]s
|
||||
FOR EACH ROW EXECUTE PROCEDURE updateFTS();
|
||||
`,
|
||||
config.DbTable)
|
||||
|
||||
config.DbStatements.Insert = fmt.Sprintf(
|
||||
`INSERT IGNORE INTO %s (qrz, dmrid, name, city, dept, country)
|
||||
VALUES (?,?,?,?,?,?);`,
|
||||
config.DbTable)
|
||||
config.DbStatements.ExportCSV = fmt.Sprintf(
|
||||
`SELECT qrz, name, city, dept, country
|
||||
FROM %s;`,
|
||||
config.DbStatements.Insert = fmt.Sprintf(`
|
||||
INSERT INTO %[1]s (qrz, dmrid, name, city, dept, country)
|
||||
VALUES ($1, $2, $3, $4, $5, $6);
|
||||
`,
|
||||
config.DbTable)
|
||||
|
||||
config.DbStatements.Countries = fmt.Sprintf(
|
||||
`SELECT country
|
||||
FROM %s
|
||||
GROUP BY country;`,
|
||||
config.DbStatements.ExportCSV = fmt.Sprintf(`
|
||||
SELECT qrz, name, city, dept, country
|
||||
FROM %[1]s;
|
||||
`,
|
||||
config.DbTable)
|
||||
|
||||
config.DbStatements.Countries = fmt.Sprintf(`
|
||||
SELECT country
|
||||
FROM %[1]s
|
||||
GROUP BY country;
|
||||
`,
|
||||
config.DbTable)
|
||||
|
||||
config.URLBase = `http://groupe-frs.hamstation.eu/index_qrz_liste_%s.php`
|
||||
|
@ -168,4 +168,5 @@ type FrsEntry struct {
|
||||
ZipCode sql.NullString `db:"zipcode"`
|
||||
Dept sql.NullString `db:"dept"`
|
||||
Country sql.NullString `db:"country"`
|
||||
Fts sql.NullString `db:"fts"`
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ func BuildQuery(config config.Config, qrzdt QrzDatatableInput) (rows *sqlx.Rows,
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
searchstatement, err = SetSearchStatement(config, qrzdt)
|
||||
searchstatement, err = SetSearchLikeStatement(config, qrzdt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -120,16 +120,36 @@ func BuildQuery(config config.Config, qrzdt QrzDatatableInput) (rows *sqlx.Rows,
|
||||
}
|
||||
|
||||
// BuildQueryCountFiltered builds query for counting filtered
|
||||
<<<<<<< Updated upstream
|
||||
func BuildQueryCountFiltered(config config.Config, qrzdt QrzDatatableInput) (cnt int, err error) {
|
||||
searchstatement, err := SetSearchStatement(config, qrzdt)
|
||||
err = config.Db.Get(&cnt, fmt.Sprintf("SELECT COUNT(*) FROM %s WHERE %s;", config.DbTable, searchstatement))
|
||||
=======
|
||||
func BuildQueryCountFiltered(config config.Config, qrzdt DatatableInput) (cnt int, err error) {
|
||||
searchstatement, err := SetSearchLikeStatement(config, qrzdt)
|
||||
|
||||
query := `
|
||||
SELECT COUNT(*)
|
||||
FROM %s
|
||||
WHERE %s;`
|
||||
|
||||
err = config.Db.Get(&cnt, fmt.Sprintf(query, config.DbTable, searchstatement))
|
||||
>>>>>>> Stashed changes
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// BuildQueryCountTotal builds query for counting totals
|
||||
<<<<<<< Updated upstream
|
||||
func BuildQueryCountTotal(config config.Config, qrzdt QrzDatatableInput) (cnt int, err error) {
|
||||
err = config.Db.Get(&cnt, fmt.Sprintf("SELECT COUNT(*) FROM %s;", config.DbTable))
|
||||
=======
|
||||
func BuildQueryCountTotal(config config.Config, qrzdt DatatableInput) (cnt int, err error) {
|
||||
query := `
|
||||
SELECT COUNT(*) FROM %s;
|
||||
`
|
||||
err = config.Db.Get(&cnt, fmt.Sprintf(query, config.DbTable))
|
||||
>>>>>>> Stashed changes
|
||||
|
||||
return
|
||||
}
|
||||
@ -190,8 +210,13 @@ func SetLimitStatement(config config.Config, qrzdt QrzDatatableInput) (limitstmt
|
||||
return
|
||||
}
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
// SetSearchStatement build the where clause in sql statement
|
||||
func SetSearchStatement(config config.Config, qrzdt QrzDatatableInput) (searchstmt string, err error) {
|
||||
=======
|
||||
// SetSearchLikeStatement build the where clause in sql statement
|
||||
func SetSearchLikeStatement(config config.Config, qrzdt DatatableInput) (searchstmt string, err error) {
|
||||
>>>>>>> Stashed changes
|
||||
var searchstmtslice []string
|
||||
if len(qrzdt.Columns) > 0 {
|
||||
for id, i := range qrzdt.Columns {
|
||||
@ -208,6 +233,16 @@ func SetSearchStatement(config config.Config, qrzdt QrzDatatableInput) (searchst
|
||||
return
|
||||
}
|
||||
|
||||
// SetSearchFTSStatement build the where clause in sql statement
|
||||
func SetSearchFTSStatement(config config.Config, qrzdt DatatableInput) (searchstmt string, err error) {
|
||||
if len(qrzdt.Columns) > 0 {
|
||||
searchstmt = fmt.Sprintf("fts @@ plainto_tsquery('%s')", qrzdt.Search.Value)
|
||||
} else {
|
||||
searchstmt = "1=1"
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// RunCSVExport runs the main loop
|
||||
func RunCSVExport(c echo.Context, config config.Config) (data []byte, mime string, err error) {
|
||||
mime = "text/csv"
|
||||
|
@ -2,3 +2,18 @@ body
|
||||
{
|
||||
font-family: "Helvetica Neue", "HelveticaNeue", "Helvetica", "Arial", "sans-serif";
|
||||
}
|
||||
<<<<<<< Updated upstream
|
||||
=======
|
||||
|
||||
#main_table_length
|
||||
{
|
||||
float: left;
|
||||
}
|
||||
|
||||
#main_table_filter
|
||||
{
|
||||
float: right;
|
||||
}
|
||||
|
||||
#main_table_paginate
|
||||
>>>>>>> Stashed changes
|
||||
|
@ -3,14 +3,22 @@
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="static/css/main.css" media="screen">
|
||||
<link rel="stylesheet" type="text/css" href="static/css/font-awesome/all.css">
|
||||
<<<<<<< Updated upstream
|
||||
<link rel="stylesheet" type="text/css" href="static/css/bootstrap.css">
|
||||
<link rel="stylesheet" type="text/css" href="static/css/materialize.min.css">
|
||||
=======
|
||||
<link rel="stylesheet" type="text/css" href="static/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="static/css/dataTables.bootstrap4.min.css">
|
||||
>>>>>>> Stashed changes
|
||||
|
||||
<script type="text/javascript" src="static/js/jquery.js"></script>
|
||||
<script type="text/javascript" src="static/js/jquery.dataTables.min.js"></script>
|
||||
<script type="text/javascript" src="static/js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" src="static/js/dataTables.bootstrap4.min.js"></script>
|
||||
<<<<<<< Updated upstream
|
||||
<script type="text/javascript" src="static/js/materialize.min.js"></script>
|
||||
=======
|
||||
>>>>>>> Stashed changes
|
||||
<script type="text/javascript" src="static/js/axios.min.js"></script>
|
||||
<script type="text/javascript" src="static/js/vue.min.js"></script>
|
||||
<script type="text/javascript" src="static/js/datatable.js"></script>
|
||||
@ -21,7 +29,11 @@
|
||||
<h1 class="display-3">FRS QRZ database</h1>
|
||||
<p>Mirror of <a href="http://groupe-frs.hamstation.eu">http://groupe-frs.hamstation.eu</a> list of users</p>
|
||||
<div>
|
||||
<<<<<<< Updated upstream
|
||||
<table id="main_table" class="striped highlight responsive-table">
|
||||
=======
|
||||
<table id="main_table" class="display table table-hover">
|
||||
>>>>>>> Stashed changes
|
||||
<thead class="thead-dark">
|
||||
<tr>
|
||||
<td>QRZ</td>
|
||||
|
Loading…
Reference in New Issue
Block a user