difftrack/

directory
v5.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2021 License: MIT

README

Difftrack example

To go back to Vostok: here.


Introduction

This example illustrates several things:

  • how the tracking is set for some entities
  • how to get the diffs

Top


Building the project & starting the server

To build

go build -i -o $GOPATH/src/bitbucket.org/oscaroscar/vostok/examples/difftrack/bin/dt -v bitbucket.org/oscaroscar/vostok/examples/difftrack/go

To run:

cd $GOPATH/src/bitbucket.org/oscaroscar/vostok/examples/difftrack && ./bin/dt -config=conf/example.dev.localhost.json

Top


Checking the data

curl http://localhost:10101/difftrack/rest/contact/list/-1
curl http://localhost:10101/difftrack/rest/project/list/-1

Top


Updating the data

curl -X POST -H "Content-Type: application/json"               \
-H "Authorization: Bearer $(difftrack-token-admin)"            \
--url http://localhost:10101/difftrack/rest/project/update/NEW \
-d '{
      "kind": "project",
      "id": 1,
      "reference": "NEW",
      "name": "My New Project",
      "description": "this is my super cool project UPDATED",
      "active": false,
      "price": 150000.00,
      "mainContactVOID": "",
      "contacts": [
        {
          "kind": "contact",
          "id": 3,
          "reference": "ABI",
          "firstName": "Aimie",
          "lastName": "Bigail",
          "involvedIn": null
        }
      ]
    }'

Check the changes on the entity itself:

curl http://localhost:10101/difftrack/rest/project/list/-1

Top


Checking the diffs

Check the changes themselves:

curl http://localhost:10101/difftrack/rest/entitydifference/search/project::NEW

You can also check the changes in the DB:

mysql> select * from entityDifference;
+----+-----------------+------------------+-------------+----------------------------+--------------+--------------+--------------+
| id | basicDifference | createdBy        | createdByID | creation                   | entityStatus | sourceEntity | targetEntity |
+----+-----------------+------------------+-------------+----------------------------+--------------+--------------+--------------+
|  1 | NULL            | User # 0 (Admin) |           1 | 2020-10-14 14:01:26.598914 |            1 | project::NEW | project::NEW |
+----+-----------------+------------------+-------------+----------------------------+--------------+--------------+--------------+

mysql> select * from fieldDifference;
+----+------------------+-------------+----------------------------+--------------+-------------+----------+---------------------------------------+-------------------------------+
| id | createdBy        | createdByID | creation                   | entityStatus | fieldName   | owner_id | valueAfter                            | valueBefore                   |
+----+------------------+-------------+----------------------------+--------------+-------------+----------+---------------------------------------+-------------------------------+
|  1 | User # 0 (Admin) |           1 | 2020-10-14 14:01:26.603910 |            1 | Active      |        1 | false                                 | true                          |
|  2 | User # 0 (Admin) |           1 | 2020-10-14 14:01:26.604784 |            1 | Description |        1 | this is my super cool project UPDATED | this is my super cool project |
|  3 | User # 0 (Admin) |           1 | 2020-10-14 14:01:26.605072 |            1 | Price       |        1 | 150000                                | 148021.55                     |
+----+------------------+-------------+----------------------------+--------------+-------------+----------+---------------------------------------+-------------------------------+

mysql> select * from linkDifference;
+----+--------------+------------------+-------------+----------------------------+--------------+-------------+----------+--------------+
| id | added        | createdBy        | createdByID | creation                   | entityStatus | linkName    | owner_id | removed      |
+----+--------------+------------------+-------------+----------------------------+--------------+-------------+----------+--------------+
|  1 | contact::ABI | User # 0 (Admin) |           1 | 2020-10-14 14:01:26.600737 |            1 | Contacts    |        1 | NULL         |
|  2 | NULL         | User # 0 (Admin) |           1 | 2020-10-14 14:01:26.602059 |            1 | Contacts    |        1 | contact::JCD |
|  3 | NULL         | User # 0 (Admin) |           1 | 2020-10-14 14:01:26.602845 |            1 | Contacts    |        1 | contact::THA |
|  4 | NULL         | User # 0 (Admin) |           1 | 2020-10-14 14:01:26.603594 |            1 | MainContact |        1 | contact::JCD |
+----+--------------+------------------+-------------+----------------------------+--------------+-------------+----------+--------------+

Top

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL