Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
HaseProgram committed Jan 12, 2018
1 parent 87c0f6a commit 96bd6dd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func Connect() {
}

var err error
DB, err = pgx.NewConnPool(pgx.ConnPoolConfig{ConnConfig: connection, MaxConnections: 10})
DB, err = pgx.NewConnPool(pgx.ConnPoolConfig{ConnConfig: connection, MaxConnections: 50})
if err != nil {
panic(err)
}
Expand Down
16 changes: 8 additions & 8 deletions db.sql
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
SET SYNCHRONOUS_COMMIT = 'off';
CREATE EXTENSION IF NOT EXISTS CITEXT;

DROP TABLE forums;
DROP TABLE threads;
DROP TABLE posts;
DROP TABLE forum_users;
DROP TABLE thread_votes;
DROP TABLE users;

CREATE TABLE IF NOT EXISTS users (
DROP TABLE IF EXISTS forums;
DROP TABLE IF EXISTS threads;
DROP TABLE IF EXISTS posts;
DROP TABLE IF EXISTS forum_users;
DROP TABLE IF EXISTS thread_votes;
DROP TABLE IF EXISTS users;

CREATE TABLE users (
id SERIAL PRIMARY KEY,
about TEXT DEFAULT NULL,
email CITEXT UNIQUE,
Expand Down
2 changes: 0 additions & 2 deletions mian.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import (
"github.com/go-ozzo/ozzo-routing"
"github.com/go-ozzo/ozzo-routing/slash"
"github.com/HaseProgram/technoparkdb/user"

"github.com/HaseProgram/technoparkdb/forum"
"github.com/HaseProgram/technoparkdb/thread"
"github.com/HaseProgram/technoparkdb/database"
"github.com/HaseProgram/technoparkdb/post"
"github.com/HaseProgram/technoparkdb/service"
_ "net/http/pprof"
)

var router *routing.Router
Expand Down
8 changes: 4 additions & 4 deletions post/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,16 @@ func Create(c *routing.Context) (string, int) {
}

var CheckPostArr []CheckPost
db.Prepare("select_user", "SELECT id, nickname FROM users WHERE nickname=$1")
db.Prepare("get_parent","SELECT thread_id FROM posts WHERE id=$1")
transaction.Prepare("select_user", "SELECT id, nickname FROM users WHERE nickname=$1")
transaction.Prepare("get_parent","SELECT thread_id FROM posts WHERE id=$1")

//batch := db.BeginBatch()
for _, post := range POST {
var ta CheckPost

ta.AuthorId = -1

row := db.QueryRow("select_user", post.AuthorName)
row := transaction.QueryRow("select_user", post.AuthorName)
err := row.Scan(&ta.AuthorId, &ta.AuthorName)

if ta.AuthorId < 0 {
Expand Down Expand Up @@ -146,7 +146,7 @@ func Create(c *routing.Context) (string, int) {

res := make([]PostStruct, 0)

db.Prepare("insert_post", insertStatement)
transaction.Prepare("insert_post", insertStatement)

for index, post := range POST {
var tres PostStruct
Expand Down

0 comments on commit 96bd6dd

Please sign in to comment.