comparison pkg/models/import.go @ 1023:337a7f4c8a16

Add endpoint to list all or some import jobs. Unpaged path: /api/imports Paged path: /api/imports?offset=[0-9+]&limit=[0-9]+
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 24 Oct 2018 12:24:26 +0200
parents
children 3de54d7b7d30
comparison
equal deleted inserted replaced
1022:74229d9f7028 1023:337a7f4c8a16
1 // This is Free Software under GNU Affero General Public License v >= 3.0
2 // without warranty, see README.md and license for details.
3 //
4 // SPDX-License-Identifier: AGPL-3.0-or-later
5 // License-Filename: LICENSES/AGPL-3.0.txt
6 //
7 // Copyright (C) 2018 by via donau
8 // – Österreichische Wasserstraßen-Gesellschaft mbH
9 // Software engineering by Intevation GmbH
10 //
11 // Author(s):
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de>
13
14 package models
15
16 import (
17 "encoding/json"
18 "time"
19 )
20
21 type (
22 ImportTime struct{ time.Time }
23
24 Import struct {
25 ID int64 `json:"id"`
26 State string `json:"state"`
27 Enqueued ImportTime `json:"enqueued"`
28 Kind string `json:"kind"`
29 User string `json:"user"`
30 }
31 )
32
33 func (it ImportTime) MarshalJSON() ([]byte, error) {
34 return json.Marshal(it.Format("2006-01-02T15:04:05"))
35 }
36
37 func (it *ImportTime) Scan(x interface{}) error {
38 t, ok := x.(time.Time)
39 if !ok {
40 *it = ImportTime{}
41 } else {
42 *it = ImportTime{t}
43 }
44 return nil
45 }