Compare commits
No commits in common. "main" and "v3.4.3" have entirely different histories.
4 changed files with 11 additions and 44 deletions
|
@ -1,4 +1,4 @@
|
||||||
FROM golang:1.23.1 as build
|
FROM golang:1.21.4 as build
|
||||||
|
|
||||||
LABEL author="vlbeaudoin"
|
LABEL author="vlbeaudoin"
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,9 @@ Nécessite une installation fonctionnelle et accessible de [agecem/bottin](https
|
||||||
|
|
||||||
Remplir .env avec données d'environnement:
|
Remplir .env avec données d'environnement:
|
||||||
```
|
```
|
||||||
BOTTINAGENDA_DB_DATABASE=bottin-agenda
|
BOTTINAGENDA_POSTGRES_DATABASE=bottin-agenda
|
||||||
BOTTINAGENDA_DB_PASSWORD=bottin-agenda
|
BOTTINAGENDA_POSTGRES_PASSWORD=bottin-agenda
|
||||||
BOTTINAGENDA_DB_USER=bottin-agenda
|
BOTTINAGENDA_POSTGRES_USER=bottin-agenda
|
||||||
```
|
```
|
||||||
|
|
||||||
Déployer avec docker-compose:
|
Déployer avec docker-compose:
|
||||||
|
|
|
@ -90,24 +90,7 @@ func (d *DataClient) InsertTransactions(transactions []models.Transaction) ([]mo
|
||||||
return rowsInserted, errors.New("Impossible d'insérer une transaction sans membre_id")
|
return rowsInserted, errors.New("Impossible d'insérer une transaction sans membre_id")
|
||||||
}
|
}
|
||||||
|
|
||||||
rows, err := tx.NamedQuery(`
|
rows, err := tx.NamedQuery("INSERT INTO transactions (membre_id, given_at, is_perpetual) VALUES (:membre_id, current_timestamp, :is_perpetual) RETURNING id, membre_id, is_perpetual;", &transaction)
|
||||||
INSERT INTO
|
|
||||||
transactions (
|
|
||||||
membre_id,
|
|
||||||
given_at,
|
|
||||||
is_perpetual
|
|
||||||
)
|
|
||||||
VALUES
|
|
||||||
(
|
|
||||||
:membre_id,
|
|
||||||
current_timestamp,
|
|
||||||
:is_perpetual
|
|
||||||
)
|
|
||||||
RETURNING
|
|
||||||
id,
|
|
||||||
membre_id,
|
|
||||||
is_perpetual;
|
|
||||||
`, &transaction)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return rowsInserted, err
|
return rowsInserted, err
|
||||||
}
|
}
|
||||||
|
@ -134,16 +117,8 @@ RETURNING
|
||||||
func (d *DataClient) GetTransaction(membreID string, is_perpetual bool) (models.Transaction, error) {
|
func (d *DataClient) GetTransaction(membreID string, is_perpetual bool) (models.Transaction, error) {
|
||||||
var transaction models.Transaction
|
var transaction models.Transaction
|
||||||
|
|
||||||
err := d.DB.Get(&transaction, `
|
//err := d.DB.NamedQuery("SELECT * FROM transactions WHERE membre_id=:membre_id AND is_perpetual=:is_perpetual LIMIT 1;"
|
||||||
SELECT
|
err := d.DB.Get(&transaction, "SELECT * FROM transactions WHERE membre_id = $1 AND is_perpetual = $2 LIMIT 1;", membreID, is_perpetual)
|
||||||
*
|
|
||||||
FROM
|
|
||||||
transactions
|
|
||||||
WHERE
|
|
||||||
membre_id = $1 AND
|
|
||||||
is_perpetual = $2
|
|
||||||
LIMIT 1;
|
|
||||||
`, membreID, is_perpetual)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return transaction, err
|
return transaction, err
|
||||||
}
|
}
|
||||||
|
@ -157,13 +132,7 @@ LIMIT 1;
|
||||||
|
|
||||||
func (d *DataClient) ListTransactions() ([]models.Transaction, error) {
|
func (d *DataClient) ListTransactions() ([]models.Transaction, error) {
|
||||||
var transactions []models.Transaction
|
var transactions []models.Transaction
|
||||||
if err := d.DB.Select(&transactions, `
|
if err := d.DB.Select(&transactions, "SELECT * FROM transactions LIMIT 20000;"); err != nil {
|
||||||
SELECT
|
|
||||||
*
|
|
||||||
FROM
|
|
||||||
transactions
|
|
||||||
LIMIT 20000;
|
|
||||||
`); err != nil {
|
|
||||||
return transactions, err
|
return transactions, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,9 @@ services:
|
||||||
db:
|
db:
|
||||||
image: 'docker.io/library/postgres:16.1'
|
image: 'docker.io/library/postgres:16.1'
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_DATABASE: "${BOTTINAGENDA_DB_DATABASE:?}"
|
POSTGRES_DATABASE: "${BOTTINAGENDA_POSTGRES_DATABASE}"
|
||||||
POSTGRES_PASSWORD: "${BOTTINAGENDA_DB_PASSWORD:?}"
|
POSTGRES_PASSWORD: "${BOTTINAGENDA_POSTGRES_PASSWORD}"
|
||||||
POSTGRES_USER: "${BOTTINAGENDA_DB_USER:?}"
|
POSTGRES_USER: "${BOTTINAGENDA_POSTGRES_USER}"
|
||||||
volumes:
|
volumes:
|
||||||
- 'db-data:/var/lib/postgresql/data'
|
- 'db-data:/var/lib/postgresql/data'
|
||||||
restart: 'unless-stopped'
|
restart: 'unless-stopped'
|
||||||
|
@ -14,7 +14,6 @@ services:
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
build: .
|
build: .
|
||||||
env_file: '.env'
|
|
||||||
image: 'git.agecem.com/agecem/bottin-agenda:latest'
|
image: 'git.agecem.com/agecem/bottin-agenda:latest'
|
||||||
ports:
|
ports:
|
||||||
- '1313:1313'
|
- '1313:1313'
|
||||||
|
@ -27,7 +26,6 @@ services:
|
||||||
depends_on:
|
depends_on:
|
||||||
- api
|
- api
|
||||||
build: .
|
build: .
|
||||||
env_file: '.env'
|
|
||||||
image: 'git.agecem.com/agecem/bottin-agenda:latest'
|
image: 'git.agecem.com/agecem/bottin-agenda:latest'
|
||||||
ports:
|
ports:
|
||||||
- '2313:2313'
|
- '2313:2313'
|
||||||
|
|
Reference in a new issue