dao-treasury 0.0.29__tar.gz → 0.0.31__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/PKG-INFO +36 -4
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/README.md +35 -3
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/dao_treasury/.grafana/provisioning/dashboards/dashboards.yaml +8 -0
- dao_treasury-0.0.31/dao_treasury/.grafana/provisioning/dashboards/streams/LlamaPay.json +116 -0
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/dao_treasury/.grafana/provisioning/dashboards/treasury/Cashflow.json +22 -22
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/dao_treasury/_docker.py +23 -18
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/dao_treasury/db.py +172 -16
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/dao_treasury/docker-compose.yaml +1 -0
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/dao_treasury/main.py +27 -3
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/dao_treasury/sorting/__init__.py +1 -0
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/dao_treasury/sorting/rule.py +5 -0
- dao_treasury-0.0.31/dao_treasury/sorting/rules/__init__.py +1 -0
- dao_treasury-0.0.31/dao_treasury/sorting/rules/ignore/__init__.py +1 -0
- dao_treasury-0.0.31/dao_treasury/sorting/rules/ignore/llamapay.py +20 -0
- dao_treasury-0.0.31/dao_treasury/streams/__init__.py +0 -0
- dao_treasury-0.0.31/dao_treasury/streams/llamapay.py +363 -0
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/dao_treasury/treasury.py +25 -4
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/dao_treasury.egg-info/PKG-INFO +36 -4
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/dao_treasury.egg-info/SOURCES.txt +7 -1
- dao_treasury-0.0.31/dao_treasury.egg-info/requires.txt +1 -0
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/pyproject.toml +3 -3
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/setup.py +2 -0
- dao_treasury-0.0.29/dao_treasury.egg-info/requires.txt +0 -1
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/MANIFEST.in +0 -0
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/dao_treasury/.grafana/provisioning/dashboards/summary/Monthly.json +0 -0
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/dao_treasury/.grafana/provisioning/dashboards/transactions/Treasury Transactions.json +0 -0
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/dao_treasury/.grafana/provisioning/dashboards/treasury/Treasury.json +0 -0
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/dao_treasury/.grafana/provisioning/datasources/datasources.yaml +0 -0
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/dao_treasury/ENVIRONMENT_VARIABLES.py +0 -0
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/dao_treasury/__init__.py +0 -0
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/dao_treasury/_nicknames.py +0 -0
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/dao_treasury/_wallet.py +0 -0
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/dao_treasury/constants.py +0 -0
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/dao_treasury/py.typed +0 -0
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/dao_treasury/sorting/_matchers.py +0 -0
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/dao_treasury/sorting/_rules.py +0 -0
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/dao_treasury/sorting/factory.py +0 -0
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/dao_treasury/types.py +0 -0
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/dao_treasury.egg-info/dependency_links.txt +0 -0
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/dao_treasury.egg-info/not-zip-safe +0 -0
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/dao_treasury.egg-info/top_level.txt +0 -0
- {dao_treasury-0.0.29 → dao_treasury-0.0.31}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: dao_treasury
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.31
|
4
4
|
Summary: Produce comprehensive financial reports for your on-chain org
|
5
5
|
Classifier: Development Status :: 3 - Alpha
|
6
6
|
Classifier: Intended Audience :: Developers
|
@@ -31,7 +31,7 @@ DAO Treasury is a comprehensive financial reporting and treasury management solu
|
|
31
31
|
|
32
32
|
## Prerequisites
|
33
33
|
|
34
|
-
- First, you will need to bring your own archive node. This can be one you run yourself, or one from one of the common providers (Tenderly, Alchemy, QuickNode, etc.)
|
34
|
+
- First, you will need to bring your own archive node. This can be one you run yourself, or one from one of the common providers (Tenderly, Alchemy, QuickNode, etc.). Your archive node must have tracing enabled (free-tier Alchemy nodes do not support this option).
|
35
35
|
- You must configure a [brownie network](https://eth-brownie.readthedocs.io/en/stable/network-management.html) to use your RPC.
|
36
36
|
- You will need an auth token for [Etherscan](https://etherscan.io/)'s API. Follow their [guide](https://docs.etherscan.io/etherscan-v2/getting-an-api-key) to get your key, and set env var `ETHERSCAN_TOKEN` with its value.
|
37
37
|
- You'll also need [Docker](https://www.docker.com/get-started/) installed on your system. If on MacOS, you will need to leave Docker Desktop open while Yearn Treasury is running.
|
@@ -61,13 +61,43 @@ poetry run dao-treasury run --wallet 0x123 --network mainnet --interval 12h
|
|
61
61
|
- `--interval`: The time interval between each data snapshot (default: 12h)
|
62
62
|
- `--daemon`: Run the export process in the background (default: False) (NOTE: currently unsupported)
|
63
63
|
- `--grafana-port`: Set the port for the Grafana dashboard where you can view data (default: 3004)
|
64
|
-
- `--renderer-port`: Set the port for the report rendering service (default:
|
64
|
+
- `--renderer-port`: Set the port for the report rendering service (default: 8091)
|
65
65
|
- `--victoria-port`: Set the port for the Victoria metrics reporting endpoint (default: 8430)
|
66
|
+
- `--start-renderer`: If set, both the Grafana and renderer containers will be started for dashboard image export. By default, only the grafana container is started.
|
66
67
|
|
67
68
|
After running the command, the export script will run continuously until you close your terminal.
|
68
69
|
To view the dashboards, just open your browser and navigate to [http://localhost:3004](http://localhost:3004)!
|
69
70
|
|
70
|
-
|
71
|
+
## Docker
|
72
|
+
|
73
|
+
When you run DAO Treasury, [eth-portfolio](https://github.com/BobTheBuidler/eth-portfolio) will build and start 4 [required Docker containers](https://bobthebuidler.github.io/eth-portfolio/exporter.html#docker-containers) on your system. Additionally, DAO Treasury will build and start 2 more required containers:
|
74
|
+
|
75
|
+
- **grafana**
|
76
|
+
- Provides a web-based dashboard for visualizing your treasury data.
|
77
|
+
- Pre-configured with dashboards and plugins for real-time monitoring.
|
78
|
+
- Uses persistent storage to retain dashboard settings and data.
|
79
|
+
- Accessible locally (default port `3004`, configurable via `--grafana-port`).
|
80
|
+
- Supports anonymous access for convenience.
|
81
|
+
- Integrates with the renderer container for dashboard image export.
|
82
|
+
- Loads dashboards and data sources automatically via provisioning files.
|
83
|
+
|
84
|
+
- **renderer**
|
85
|
+
- Runs the official Grafana image renderer service.
|
86
|
+
- Enables Grafana to export dashboards as images for reporting or sharing.
|
87
|
+
- Operates on port `8091` by default (configurable via `--renderer-port`).
|
88
|
+
- Tightly integrated with the Grafana container for seamless image rendering.
|
89
|
+
- **Note:** The renderer container is only started if you pass the `--start-renderer` CLI flag.
|
90
|
+
|
91
|
+
**How it works:**
|
92
|
+
1. DAO Treasury collects and exports treasury data.
|
93
|
+
2. Grafana displays this data in pre-built dashboards for analysis and reporting.
|
94
|
+
3. The renderer container allows dashboards to be exported as images directly from Grafana (if enabled).
|
95
|
+
|
96
|
+
**Additional Information:**
|
97
|
+
- All containers are orchestrated via Docker Compose and started automatically as needed.
|
98
|
+
- Grafana provisioning ensures dashboards and data sources are set up out-of-the-box.
|
99
|
+
- All dashboard data and settings are persisted for durability.
|
100
|
+
- Dashboard images can be generated for reporting via the renderer (if enabled).
|
71
101
|
|
72
102
|
## Screenshots
|
73
103
|
|
@@ -78,3 +108,5 @@ Enjoy!
|
|
78
108
|
## Contributing
|
79
109
|
|
80
110
|
We welcome contributions to DAO Treasury! For detailed guidelines on how to contribute, please see the [Contributing Guidelines](https://github.com/BobTheBuidler/dao-treasury/blob/master/CONTRIBUTING.md).
|
111
|
+
|
112
|
+
Enjoy!
|
@@ -14,7 +14,7 @@ DAO Treasury is a comprehensive financial reporting and treasury management solu
|
|
14
14
|
|
15
15
|
## Prerequisites
|
16
16
|
|
17
|
-
- First, you will need to bring your own archive node. This can be one you run yourself, or one from one of the common providers (Tenderly, Alchemy, QuickNode, etc.)
|
17
|
+
- First, you will need to bring your own archive node. This can be one you run yourself, or one from one of the common providers (Tenderly, Alchemy, QuickNode, etc.). Your archive node must have tracing enabled (free-tier Alchemy nodes do not support this option).
|
18
18
|
- You must configure a [brownie network](https://eth-brownie.readthedocs.io/en/stable/network-management.html) to use your RPC.
|
19
19
|
- You will need an auth token for [Etherscan](https://etherscan.io/)'s API. Follow their [guide](https://docs.etherscan.io/etherscan-v2/getting-an-api-key) to get your key, and set env var `ETHERSCAN_TOKEN` with its value.
|
20
20
|
- You'll also need [Docker](https://www.docker.com/get-started/) installed on your system. If on MacOS, you will need to leave Docker Desktop open while Yearn Treasury is running.
|
@@ -44,13 +44,43 @@ poetry run dao-treasury run --wallet 0x123 --network mainnet --interval 12h
|
|
44
44
|
- `--interval`: The time interval between each data snapshot (default: 12h)
|
45
45
|
- `--daemon`: Run the export process in the background (default: False) (NOTE: currently unsupported)
|
46
46
|
- `--grafana-port`: Set the port for the Grafana dashboard where you can view data (default: 3004)
|
47
|
-
- `--renderer-port`: Set the port for the report rendering service (default:
|
47
|
+
- `--renderer-port`: Set the port for the report rendering service (default: 8091)
|
48
48
|
- `--victoria-port`: Set the port for the Victoria metrics reporting endpoint (default: 8430)
|
49
|
+
- `--start-renderer`: If set, both the Grafana and renderer containers will be started for dashboard image export. By default, only the grafana container is started.
|
49
50
|
|
50
51
|
After running the command, the export script will run continuously until you close your terminal.
|
51
52
|
To view the dashboards, just open your browser and navigate to [http://localhost:3004](http://localhost:3004)!
|
52
53
|
|
53
|
-
|
54
|
+
## Docker
|
55
|
+
|
56
|
+
When you run DAO Treasury, [eth-portfolio](https://github.com/BobTheBuidler/eth-portfolio) will build and start 4 [required Docker containers](https://bobthebuidler.github.io/eth-portfolio/exporter.html#docker-containers) on your system. Additionally, DAO Treasury will build and start 2 more required containers:
|
57
|
+
|
58
|
+
- **grafana**
|
59
|
+
- Provides a web-based dashboard for visualizing your treasury data.
|
60
|
+
- Pre-configured with dashboards and plugins for real-time monitoring.
|
61
|
+
- Uses persistent storage to retain dashboard settings and data.
|
62
|
+
- Accessible locally (default port `3004`, configurable via `--grafana-port`).
|
63
|
+
- Supports anonymous access for convenience.
|
64
|
+
- Integrates with the renderer container for dashboard image export.
|
65
|
+
- Loads dashboards and data sources automatically via provisioning files.
|
66
|
+
|
67
|
+
- **renderer**
|
68
|
+
- Runs the official Grafana image renderer service.
|
69
|
+
- Enables Grafana to export dashboards as images for reporting or sharing.
|
70
|
+
- Operates on port `8091` by default (configurable via `--renderer-port`).
|
71
|
+
- Tightly integrated with the Grafana container for seamless image rendering.
|
72
|
+
- **Note:** The renderer container is only started if you pass the `--start-renderer` CLI flag.
|
73
|
+
|
74
|
+
**How it works:**
|
75
|
+
1. DAO Treasury collects and exports treasury data.
|
76
|
+
2. Grafana displays this data in pre-built dashboards for analysis and reporting.
|
77
|
+
3. The renderer container allows dashboards to be exported as images directly from Grafana (if enabled).
|
78
|
+
|
79
|
+
**Additional Information:**
|
80
|
+
- All containers are orchestrated via Docker Compose and started automatically as needed.
|
81
|
+
- Grafana provisioning ensures dashboards and data sources are set up out-of-the-box.
|
82
|
+
- All dashboard data and settings are persisted for durability.
|
83
|
+
- Dashboard images can be generated for reporting via the renderer (if enabled).
|
54
84
|
|
55
85
|
## Screenshots
|
56
86
|
|
@@ -61,3 +91,5 @@ Enjoy!
|
|
61
91
|
## Contributing
|
62
92
|
|
63
93
|
We welcome contributions to DAO Treasury! For detailed guidelines on how to contribute, please see the [Contributing Guidelines](https://github.com/BobTheBuidler/dao-treasury/blob/master/CONTRIBUTING.md).
|
94
|
+
|
95
|
+
Enjoy!
|
@@ -24,3 +24,11 @@ providers:
|
|
24
24
|
editable: false
|
25
25
|
options:
|
26
26
|
path: /etc/grafana/provisioning/dashboards/transactions
|
27
|
+
|
28
|
+
- name: 'LlamaPay Streams'
|
29
|
+
folder: 'streams'
|
30
|
+
type: file
|
31
|
+
disableDeletion: true
|
32
|
+
editable: false
|
33
|
+
options:
|
34
|
+
path: /etc/grafana/provisioning/dashboards/streams
|
@@ -0,0 +1,116 @@
|
|
1
|
+
{
|
2
|
+
"annotations": {
|
3
|
+
"list": [
|
4
|
+
{
|
5
|
+
"builtIn": 1,
|
6
|
+
"datasource": {
|
7
|
+
"type": "grafana",
|
8
|
+
"uid": "-- Grafana --"
|
9
|
+
},
|
10
|
+
"enable": true,
|
11
|
+
"hide": true,
|
12
|
+
"iconColor": "rgba(0, 211, 255, 1)",
|
13
|
+
"name": "Annotations & Alerts",
|
14
|
+
"type": "dashboard"
|
15
|
+
}
|
16
|
+
]
|
17
|
+
},
|
18
|
+
"editable": true,
|
19
|
+
"fiscalYearStartMonth": 0,
|
20
|
+
"graphTooltip": 0,
|
21
|
+
"id": 7,
|
22
|
+
"links": [],
|
23
|
+
"liveNow": false,
|
24
|
+
"panels": [
|
25
|
+
{
|
26
|
+
"datasource": {
|
27
|
+
"type": "frser-sqlite-datasource",
|
28
|
+
"uid": "P2D2EEF3E092AF52B"
|
29
|
+
},
|
30
|
+
"description": "",
|
31
|
+
"fieldConfig": {
|
32
|
+
"defaults": {
|
33
|
+
"color": {
|
34
|
+
"mode": "thresholds"
|
35
|
+
},
|
36
|
+
"custom": {
|
37
|
+
"align": "auto",
|
38
|
+
"cellOptions": {
|
39
|
+
"type": "auto"
|
40
|
+
},
|
41
|
+
"inspect": false
|
42
|
+
},
|
43
|
+
"mappings": [],
|
44
|
+
"thresholds": {
|
45
|
+
"mode": "absolute",
|
46
|
+
"steps": [
|
47
|
+
{
|
48
|
+
"color": "green",
|
49
|
+
"value": null
|
50
|
+
},
|
51
|
+
{
|
52
|
+
"color": "red",
|
53
|
+
"value": 80
|
54
|
+
}
|
55
|
+
]
|
56
|
+
}
|
57
|
+
},
|
58
|
+
"overrides": []
|
59
|
+
},
|
60
|
+
"gridPos": {
|
61
|
+
"h": 19,
|
62
|
+
"w": 24,
|
63
|
+
"x": 0,
|
64
|
+
"y": 0
|
65
|
+
},
|
66
|
+
"id": 1,
|
67
|
+
"options": {
|
68
|
+
"cellHeight": "sm",
|
69
|
+
"footer": {
|
70
|
+
"countRows": false,
|
71
|
+
"fields": "",
|
72
|
+
"reducer": [
|
73
|
+
"sum"
|
74
|
+
],
|
75
|
+
"show": false
|
76
|
+
},
|
77
|
+
"showHeader": true
|
78
|
+
},
|
79
|
+
"pluginVersion": "10.2.0",
|
80
|
+
"targets": [
|
81
|
+
{
|
82
|
+
"datasource": {
|
83
|
+
"type": "frser-sqlite-datasource",
|
84
|
+
"uid": "P2D2EEF3E092AF52B"
|
85
|
+
},
|
86
|
+
"queryText": "select stream_id as \"Stream ID\", b.address as \"Factory\", start_block as \"Start Block\", end_block as \"End Block\", c.symbol as \"Token\", d.address as \"From\", e.address as \"To\", reason as \"Reason\", amount_per_second as \"Amount Per Second\", status as \"Status\", txgroup as \"TxGroup\"\nfrom streams a\nleft join addresses b on a.contract = b.address_id\nleft join tokens c on a.token = c.token_id\nleft join addresses d on a.from_address = d.address_id\nleft join addresses e on a.to_address = e.address_id",
|
87
|
+
"queryType": "table",
|
88
|
+
"rawQueryText": "select stream_id as \"Stream ID\", b.address as \"Factory\", start_block as \"Start Block\", end_block as \"End Block\", c.symbol as \"Token\", d.address as \"From\", e.address as \"To\", reason as \"Reason\", amount_per_second as \"Amount Per Second\", status as \"Status\", txgroup as \"TxGroup\"\nfrom streams a\nleft join addresses b on a.contract = b.address_id\nleft join tokens c on a.token = c.token_id\nleft join addresses d on a.from_address = d.address_id\nleft join addresses e on a.to_address = e.address_id",
|
89
|
+
"refId": "A",
|
90
|
+
"timeColumns": [
|
91
|
+
"time",
|
92
|
+
"ts"
|
93
|
+
]
|
94
|
+
}
|
95
|
+
],
|
96
|
+
"title": "LlamaPay Streams",
|
97
|
+
"type": "table"
|
98
|
+
}
|
99
|
+
],
|
100
|
+
"refresh": "",
|
101
|
+
"schemaVersion": 38,
|
102
|
+
"tags": [],
|
103
|
+
"templating": {
|
104
|
+
"list": []
|
105
|
+
},
|
106
|
+
"time": {
|
107
|
+
"from": "now-6h",
|
108
|
+
"to": "now"
|
109
|
+
},
|
110
|
+
"timepicker": {},
|
111
|
+
"timezone": "",
|
112
|
+
"title": "LlamaPay",
|
113
|
+
"uid": "aa4d62a2-9e52-4acc-8f38-a96c77810aca",
|
114
|
+
"version": 1,
|
115
|
+
"weekStart": ""
|
116
|
+
}
|
@@ -71,9 +71,9 @@
|
|
71
71
|
"targets": [
|
72
72
|
{
|
73
73
|
"datasource": "SQLite",
|
74
|
-
"queryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT txgroup_id, name AS top_category, parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n SUM(t.value_usd) AS total_revenue\nFROM
|
74
|
+
"queryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT txgroup_id, name AS top_category, parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n SUM(t.value_usd) AS total_revenue\nFROM general_ledger t\nJOIN group_hierarchy gh USING (txgroup_id)\nWHERE gh.top_category = 'Revenue'\n AND t.timestamp >= $__from/1000\n AND t.timestamp <= $__to/1000\n",
|
75
75
|
"queryType": "table",
|
76
|
-
"rawQueryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT txgroup_id, name AS top_category, parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n SUM(t.value_usd) AS total_revenue\nFROM
|
76
|
+
"rawQueryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT txgroup_id, name AS top_category, parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n SUM(t.value_usd) AS total_revenue\nFROM general_ledger t\nJOIN group_hierarchy gh USING (txgroup_id)\nWHERE gh.top_category = 'Revenue'\n AND t.timestamp >= $__from/1000\n AND t.timestamp <= $__to/1000\n",
|
77
77
|
"refId": "A",
|
78
78
|
"timeColumns": [
|
79
79
|
"time",
|
@@ -133,9 +133,9 @@
|
|
133
133
|
"targets": [
|
134
134
|
{
|
135
135
|
"datasource": "SQLite",
|
136
|
-
"queryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT txgroup_id, name AS top_category, parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n SUM(t.value_usd) AS total_revenue\nFROM
|
136
|
+
"queryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT txgroup_id, name AS top_category, parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n SUM(t.value_usd) AS total_revenue\nFROM general_ledger t\nJOIN group_hierarchy gh USING (txgroup_id)\nWHERE gh.top_category = 'Expenses'\n AND t.timestamp >= $__from/1000\n AND t.timestamp <= $__to/1000\n",
|
137
137
|
"queryType": "table",
|
138
|
-
"rawQueryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT txgroup_id, name AS top_category, parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n SUM(t.value_usd) AS total_revenue\nFROM
|
138
|
+
"rawQueryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT txgroup_id, name AS top_category, parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n SUM(t.value_usd) AS total_revenue\nFROM general_ledger t\nJOIN group_hierarchy gh USING (txgroup_id)\nWHERE gh.top_category = 'Expenses'\n AND t.timestamp >= $__from/1000\n AND t.timestamp <= $__to/1000\n",
|
139
139
|
"refId": "A",
|
140
140
|
"timeColumns": [
|
141
141
|
"time",
|
@@ -195,9 +195,9 @@
|
|
195
195
|
"targets": [
|
196
196
|
{
|
197
197
|
"datasource": "SQLite",
|
198
|
-
"queryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT txgroup_id, name AS top_category, parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n SUM(t.value_usd) AS total_revenue\nFROM
|
198
|
+
"queryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT txgroup_id, name AS top_category, parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n SUM(t.value_usd) AS total_revenue\nFROM general_ledger t\nJOIN group_hierarchy gh USING (txgroup_id)\nWHERE gh.top_category = 'Cost of Revenue'\n AND t.timestamp >= $__from/1000\n AND t.timestamp <= $__to/1000\n",
|
199
199
|
"queryType": "table",
|
200
|
-
"rawQueryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT txgroup_id, name AS top_category, parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n SUM(t.value_usd) AS total_revenue\nFROM
|
200
|
+
"rawQueryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT txgroup_id, name AS top_category, parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n SUM(t.value_usd) AS total_revenue\nFROM general_ledger t\nJOIN group_hierarchy gh USING (txgroup_id)\nWHERE gh.top_category = 'Cost of Revenue'\n AND t.timestamp >= $__from/1000\n AND t.timestamp <= $__to/1000\n",
|
201
201
|
"refId": "A",
|
202
202
|
"timeColumns": [
|
203
203
|
"time",
|
@@ -257,9 +257,9 @@
|
|
257
257
|
"targets": [
|
258
258
|
{
|
259
259
|
"datasource": "SQLite",
|
260
|
-
"queryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT txgroup_id, name AS top_category, parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n SUM(t.value_usd) AS total_revenue\nFROM
|
260
|
+
"queryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT txgroup_id, name AS top_category, parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n SUM(t.value_usd) AS total_revenue\nFROM general_ledger t\nJOIN group_hierarchy gh USING (txgroup_id)\nWHERE gh.top_category = 'Other Income'\n AND t.timestamp >= $__from/1000\n AND t.timestamp <= $__to/1000\n",
|
261
261
|
"queryType": "table",
|
262
|
-
"rawQueryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT txgroup_id, name AS top_category, parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n SUM(t.value_usd) AS total_revenue\nFROM
|
262
|
+
"rawQueryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT txgroup_id, name AS top_category, parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n SUM(t.value_usd) AS total_revenue\nFROM general_ledger t\nJOIN group_hierarchy gh USING (txgroup_id)\nWHERE gh.top_category = 'Other Income'\n AND t.timestamp >= $__from/1000\n AND t.timestamp <= $__to/1000\n",
|
263
263
|
"refId": "A",
|
264
264
|
"timeColumns": [
|
265
265
|
"time",
|
@@ -319,9 +319,9 @@
|
|
319
319
|
"targets": [
|
320
320
|
{
|
321
321
|
"datasource": "SQLite",
|
322
|
-
"queryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT txgroup_id, name AS top_category, parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n SUM(t.value_usd) AS total_revenue\nFROM
|
322
|
+
"queryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT txgroup_id, name AS top_category, parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n SUM(t.value_usd) AS total_revenue\nFROM general_ledger t\nJOIN group_hierarchy gh USING (txgroup_id)\nWHERE gh.top_category = 'Other Expenses'\n AND t.timestamp >= $__from/1000\n AND t.timestamp <= $__to/1000\n",
|
323
323
|
"queryType": "table",
|
324
|
-
"rawQueryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT txgroup_id, name AS top_category, parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n SUM(t.value_usd) AS total_revenue\nFROM
|
324
|
+
"rawQueryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT txgroup_id, name AS top_category, parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n SUM(t.value_usd) AS total_revenue\nFROM general_ledger t\nJOIN group_hierarchy gh USING (txgroup_id)\nWHERE gh.top_category = 'Other Expenses'\n AND t.timestamp >= $__from/1000\n AND t.timestamp <= $__to/1000\n",
|
325
325
|
"refId": "A",
|
326
326
|
"timeColumns": [
|
327
327
|
"time",
|
@@ -382,9 +382,9 @@
|
|
382
382
|
"targets": [
|
383
383
|
{
|
384
384
|
"datasource": "SQLite",
|
385
|
-
"queryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT\n txgroup_id,\n name AS top_category,\n parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n (\n -- Revenue\n SUM(CASE WHEN gh.top_category = 'Revenue' THEN t.value_usd ELSE 0 END)\n -- Cost of Revenue\n - SUM(CASE WHEN gh.top_category = 'Cost of Revenue' THEN t.value_usd ELSE 0 END)\n -- Expenses\n - SUM(CASE WHEN gh.top_category = 'Expenses' THEN t.value_usd ELSE 0 END)\n -- Other Income\n + SUM(CASE WHEN gh.top_category = 'Other Income' THEN t.value_usd ELSE 0 END)\n -- Other Expenses\n - SUM(CASE WHEN gh.top_category = 'Other Expenses' THEN t.value_usd ELSE 0 END)\n ) AS total_net\nFROM
|
385
|
+
"queryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT\n txgroup_id,\n name AS top_category,\n parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n (\n -- Revenue\n SUM(CASE WHEN gh.top_category = 'Revenue' THEN t.value_usd ELSE 0 END)\n -- Cost of Revenue\n - SUM(CASE WHEN gh.top_category = 'Cost of Revenue' THEN t.value_usd ELSE 0 END)\n -- Expenses\n - SUM(CASE WHEN gh.top_category = 'Expenses' THEN t.value_usd ELSE 0 END)\n -- Other Income\n + SUM(CASE WHEN gh.top_category = 'Other Income' THEN t.value_usd ELSE 0 END)\n -- Other Expenses\n - SUM(CASE WHEN gh.top_category = 'Other Expenses' THEN t.value_usd ELSE 0 END)\n ) AS total_net\nFROM general_ledger t\nJOIN group_hierarchy gh USING (txgroup_id)\nWHERE t.timestamp >= $__from/1000\n AND t.timestamp <= $__to/1000",
|
386
386
|
"queryType": "table",
|
387
|
-
"rawQueryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT\n txgroup_id,\n name AS top_category,\n parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n (\n -- Revenue\n SUM(CASE WHEN gh.top_category = 'Revenue' THEN t.value_usd ELSE 0 END)\n -- Cost of Revenue\n - SUM(CASE WHEN gh.top_category = 'Cost of Revenue' THEN t.value_usd ELSE 0 END)\n -- Expenses\n - SUM(CASE WHEN gh.top_category = 'Expenses' THEN t.value_usd ELSE 0 END)\n -- Other Income\n + SUM(CASE WHEN gh.top_category = 'Other Income' THEN t.value_usd ELSE 0 END)\n -- Other Expenses\n - SUM(CASE WHEN gh.top_category = 'Other Expenses' THEN t.value_usd ELSE 0 END)\n ) AS total_net\nFROM
|
387
|
+
"rawQueryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT\n txgroup_id,\n name AS top_category,\n parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n (\n -- Revenue\n SUM(CASE WHEN gh.top_category = 'Revenue' THEN t.value_usd ELSE 0 END)\n -- Cost of Revenue\n - SUM(CASE WHEN gh.top_category = 'Cost of Revenue' THEN t.value_usd ELSE 0 END)\n -- Expenses\n - SUM(CASE WHEN gh.top_category = 'Expenses' THEN t.value_usd ELSE 0 END)\n -- Other Income\n + SUM(CASE WHEN gh.top_category = 'Other Income' THEN t.value_usd ELSE 0 END)\n -- Other Expenses\n - SUM(CASE WHEN gh.top_category = 'Other Expenses' THEN t.value_usd ELSE 0 END)\n ) AS total_net\nFROM general_ledger t\nJOIN group_hierarchy gh USING (txgroup_id)\nWHERE t.timestamp >= $__from/1000\n AND t.timestamp <= $__to/1000",
|
388
388
|
"refId": "A",
|
389
389
|
"timeColumns": [
|
390
390
|
"time",
|
@@ -498,9 +498,9 @@
|
|
498
498
|
"targets": [
|
499
499
|
{
|
500
500
|
"datasource": "SQLite",
|
501
|
-
"queryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT\n txgroup_id,\n name AS top_category,\n parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n t.timestamp,\n SUM(CASE WHEN gh.top_category in ('Revenue', 'Other Income') THEN t.value_usd ELSE 0 END) AS \"Total Revenue\",\n SUM(CASE WHEN gh.top_category in ('Cost of Revenue','Expenses','Other Expenses') THEN t.value_usd ELSE 0 END) * -1 AS \"Total Expenses\",\n SUM(CASE WHEN gh.top_category in ('Revenue', 'Other Income') THEN t.value_usd ELSE 0 END) - SUM(CASE WHEN gh.top_category in ('Cost of Revenue','Expenses','Other Expenses') THEN t.value_usd ELSE 0 END) AS \"Net\"\nFROM
|
501
|
+
"queryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT\n txgroup_id,\n name AS top_category,\n parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n t.timestamp,\n SUM(CASE WHEN gh.top_category in ('Revenue', 'Other Income') THEN t.value_usd ELSE 0 END) AS \"Total Revenue\",\n SUM(CASE WHEN gh.top_category in ('Cost of Revenue','Expenses','Other Expenses') THEN t.value_usd ELSE 0 END) * -1 AS \"Total Expenses\",\n SUM(CASE WHEN gh.top_category in ('Revenue', 'Other Income') THEN t.value_usd ELSE 0 END) - SUM(CASE WHEN gh.top_category in ('Cost of Revenue','Expenses','Other Expenses') THEN t.value_usd ELSE 0 END) AS \"Net\"\nFROM general_ledger AS t\nJOIN group_hierarchy gh\n ON t.txgroup_id = gh.txgroup_id\nWHERE t.timestamp >= $__from/1000\n AND t.timestamp <= $__to/1000\nGROUP BY timestamp\nORDER BY timestamp;",
|
502
502
|
"queryType": "table",
|
503
|
-
"rawQueryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT\n txgroup_id,\n name AS top_category,\n parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n t.timestamp,\n SUM(CASE WHEN gh.top_category in ('Revenue', 'Other Income') THEN t.value_usd ELSE 0 END) AS \"Total Revenue\",\n SUM(CASE WHEN gh.top_category in ('Cost of Revenue','Expenses','Other Expenses') THEN t.value_usd ELSE 0 END) * -1 AS \"Total Expenses\",\n SUM(CASE WHEN gh.top_category in ('Revenue', 'Other Income') THEN t.value_usd ELSE 0 END) - SUM(CASE WHEN gh.top_category in ('Cost of Revenue','Expenses','Other Expenses') THEN t.value_usd ELSE 0 END) AS \"Net\"\nFROM
|
503
|
+
"rawQueryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT\n txgroup_id,\n name AS top_category,\n parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n t.timestamp,\n SUM(CASE WHEN gh.top_category in ('Revenue', 'Other Income') THEN t.value_usd ELSE 0 END) AS \"Total Revenue\",\n SUM(CASE WHEN gh.top_category in ('Cost of Revenue','Expenses','Other Expenses') THEN t.value_usd ELSE 0 END) * -1 AS \"Total Expenses\",\n SUM(CASE WHEN gh.top_category in ('Revenue', 'Other Income') THEN t.value_usd ELSE 0 END) - SUM(CASE WHEN gh.top_category in ('Cost of Revenue','Expenses','Other Expenses') THEN t.value_usd ELSE 0 END) AS \"Net\"\nFROM general_ledger AS t\nJOIN group_hierarchy gh\n ON t.txgroup_id = gh.txgroup_id\nWHERE t.timestamp >= $__from/1000\n AND t.timestamp <= $__to/1000\nGROUP BY timestamp\nORDER BY timestamp;",
|
504
504
|
"refId": "A",
|
505
505
|
"timeColumns": [
|
506
506
|
"timestamp"
|
@@ -643,9 +643,9 @@
|
|
643
643
|
"targets": [
|
644
644
|
{
|
645
645
|
"datasource": "SQLite",
|
646
|
-
"queryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT txgroup_id, name AS top_category, parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n SUM(t.value_usd) AS total_revenue\nFROM
|
646
|
+
"queryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT txgroup_id, name AS top_category, parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n SUM(t.value_usd) AS total_revenue\nFROM general_ledger t\nJOIN group_hierarchy gh USING (txgroup_id)\nWHERE gh.top_category = 'Sort Me (Inbound)'\n AND t.timestamp >= $__from/1000\n AND t.timestamp <= $__to/1000\n",
|
647
647
|
"queryType": "table",
|
648
|
-
"rawQueryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT txgroup_id, name AS top_category, parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n SUM(t.value_usd) AS total_revenue\nFROM
|
648
|
+
"rawQueryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT txgroup_id, name AS top_category, parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n SUM(t.value_usd) AS total_revenue\nFROM general_ledger t\nJOIN group_hierarchy gh USING (txgroup_id)\nWHERE gh.top_category = 'Sort Me (Inbound)'\n AND t.timestamp >= $__from/1000\n AND t.timestamp <= $__to/1000\n",
|
649
649
|
"refId": "A",
|
650
650
|
"timeColumns": [
|
651
651
|
"time",
|
@@ -706,9 +706,9 @@
|
|
706
706
|
"targets": [
|
707
707
|
{
|
708
708
|
"datasource": "SQLite",
|
709
|
-
"queryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT txgroup_id, name AS top_category, parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n SUM(t.value_usd) AS total_revenue\nFROM
|
709
|
+
"queryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT txgroup_id, name AS top_category, parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n SUM(t.value_usd) AS total_revenue\nFROM general_ledger t\nJOIN group_hierarchy gh USING (txgroup_id)\nWHERE gh.top_category = 'Sort Me (Outbound)'\n AND t.timestamp >= $__from/1000\n AND t.timestamp <= $__to/1000\n",
|
710
710
|
"queryType": "table",
|
711
|
-
"rawQueryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT txgroup_id, name AS top_category, parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n SUM(t.value_usd) AS total_revenue\nFROM
|
711
|
+
"rawQueryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT txgroup_id, name AS top_category, parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n SUM(t.value_usd) AS total_revenue\nFROM general_ledger t\nJOIN group_hierarchy gh USING (txgroup_id)\nWHERE gh.top_category = 'Sort Me (Outbound)'\n AND t.timestamp >= $__from/1000\n AND t.timestamp <= $__to/1000\n",
|
712
712
|
"refId": "A",
|
713
713
|
"timeColumns": [
|
714
714
|
"time",
|
@@ -769,9 +769,9 @@
|
|
769
769
|
"targets": [
|
770
770
|
{
|
771
771
|
"datasource": "SQLite",
|
772
|
-
"queryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT\n txgroup_id,\n name AS top_category,\n parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n (\n -- Revenue\n SUM(CASE WHEN gh.top_category = 'Revenue' THEN t.value_usd ELSE 0 END)\n -- Cost of Revenue\n - SUM(CASE WHEN gh.top_category = 'Cost of Revenue' THEN t.value_usd ELSE 0 END)\n -- Expenses\n - SUM(CASE WHEN gh.top_category = 'Expenses' THEN t.value_usd ELSE 0 END)\n -- Other Income\n + SUM(CASE WHEN gh.top_category = 'Other Income' THEN t.value_usd ELSE 0 END)\n -- Other Expenses\n - SUM(CASE WHEN gh.top_category = 'Other Expenses' THEN t.value_usd ELSE 0 END)\n -- Sort Me (Inbound)\n + SUM(CASE WHEN gh.top_category = 'Sort Me (Inbound)' THEN t.value_usd ELSE 0 END)\n -- Sort Me (Outbound)\n - SUM(CASE WHEN gh.top_category = 'Sort Me (Outbound)' THEN t.value_usd ELSE 0 END)\n ) AS total_net\nFROM
|
772
|
+
"queryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT\n txgroup_id,\n name AS top_category,\n parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n (\n -- Revenue\n SUM(CASE WHEN gh.top_category = 'Revenue' THEN t.value_usd ELSE 0 END)\n -- Cost of Revenue\n - SUM(CASE WHEN gh.top_category = 'Cost of Revenue' THEN t.value_usd ELSE 0 END)\n -- Expenses\n - SUM(CASE WHEN gh.top_category = 'Expenses' THEN t.value_usd ELSE 0 END)\n -- Other Income\n + SUM(CASE WHEN gh.top_category = 'Other Income' THEN t.value_usd ELSE 0 END)\n -- Other Expenses\n - SUM(CASE WHEN gh.top_category = 'Other Expenses' THEN t.value_usd ELSE 0 END)\n -- Sort Me (Inbound)\n + SUM(CASE WHEN gh.top_category = 'Sort Me (Inbound)' THEN t.value_usd ELSE 0 END)\n -- Sort Me (Outbound)\n - SUM(CASE WHEN gh.top_category = 'Sort Me (Outbound)' THEN t.value_usd ELSE 0 END)\n ) AS total_net\nFROM general_ledger t\nJOIN group_hierarchy gh USING (txgroup_id)\nWHERE t.timestamp >= $__from/1000\n AND t.timestamp <= $__to/1000",
|
773
773
|
"queryType": "table",
|
774
|
-
"rawQueryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT\n txgroup_id,\n name AS top_category,\n parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n (\n -- Revenue\n SUM(CASE WHEN gh.top_category = 'Revenue' THEN t.value_usd ELSE 0 END)\n -- Cost of Revenue\n - SUM(CASE WHEN gh.top_category = 'Cost of Revenue' THEN t.value_usd ELSE 0 END)\n -- Expenses\n - SUM(CASE WHEN gh.top_category = 'Expenses' THEN t.value_usd ELSE 0 END)\n -- Other Income\n + SUM(CASE WHEN gh.top_category = 'Other Income' THEN t.value_usd ELSE 0 END)\n -- Other Expenses\n - SUM(CASE WHEN gh.top_category = 'Other Expenses' THEN t.value_usd ELSE 0 END)\n -- Sort Me (Inbound)\n + SUM(CASE WHEN gh.top_category = 'Sort Me (Inbound)' THEN t.value_usd ELSE 0 END)\n -- Sort Me (Outbound)\n - SUM(CASE WHEN gh.top_category = 'Sort Me (Outbound)' THEN t.value_usd ELSE 0 END)\n ) AS total_net\nFROM
|
774
|
+
"rawQueryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT\n txgroup_id,\n name AS top_category,\n parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n (\n -- Revenue\n SUM(CASE WHEN gh.top_category = 'Revenue' THEN t.value_usd ELSE 0 END)\n -- Cost of Revenue\n - SUM(CASE WHEN gh.top_category = 'Cost of Revenue' THEN t.value_usd ELSE 0 END)\n -- Expenses\n - SUM(CASE WHEN gh.top_category = 'Expenses' THEN t.value_usd ELSE 0 END)\n -- Other Income\n + SUM(CASE WHEN gh.top_category = 'Other Income' THEN t.value_usd ELSE 0 END)\n -- Other Expenses\n - SUM(CASE WHEN gh.top_category = 'Other Expenses' THEN t.value_usd ELSE 0 END)\n -- Sort Me (Inbound)\n + SUM(CASE WHEN gh.top_category = 'Sort Me (Inbound)' THEN t.value_usd ELSE 0 END)\n -- Sort Me (Outbound)\n - SUM(CASE WHEN gh.top_category = 'Sort Me (Outbound)' THEN t.value_usd ELSE 0 END)\n ) AS total_net\nFROM general_ledger t\nJOIN group_hierarchy gh USING (txgroup_id)\nWHERE t.timestamp >= $__from/1000\n AND t.timestamp <= $__to/1000",
|
775
775
|
"refId": "A",
|
776
776
|
"timeColumns": [
|
777
777
|
"time",
|
@@ -885,9 +885,9 @@
|
|
885
885
|
"targets": [
|
886
886
|
{
|
887
887
|
"datasource": "SQLite",
|
888
|
-
"queryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT\n txgroup_id,\n name AS top_category,\n parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n t.timestamp,\n SUM(CASE WHEN gh.top_category in ('Revenue', 'Other Income','Sort Me (Inbound)') THEN t.value_usd ELSE 0 END) AS \"Total Revenue (incl. Unsorted)\",\n SUM(CASE WHEN gh.top_category in ('Cost of Revenue','Expenses','Other Expenses','Sort Me (Outbound)') THEN t.value_usd ELSE 0 END) * -1 AS \"Total Expenses (incl. Unsorted)\",\n SUM(CASE WHEN gh.top_category in ('Revenue', 'Other Income','Sort Me (Inbound)') THEN t.value_usd ELSE 0 END) - SUM(CASE WHEN gh.top_category in ('Cost of Revenue','Expenses','Other Expenses','Sort Me (Outbound)') THEN t.value_usd ELSE 0 END) AS \"Net (incl. Unsorted)\"\nFROM
|
888
|
+
"queryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT\n txgroup_id,\n name AS top_category,\n parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n t.timestamp,\n SUM(CASE WHEN gh.top_category in ('Revenue', 'Other Income','Sort Me (Inbound)') THEN t.value_usd ELSE 0 END) AS \"Total Revenue (incl. Unsorted)\",\n SUM(CASE WHEN gh.top_category in ('Cost of Revenue','Expenses','Other Expenses','Sort Me (Outbound)') THEN t.value_usd ELSE 0 END) * -1 AS \"Total Expenses (incl. Unsorted)\",\n SUM(CASE WHEN gh.top_category in ('Revenue', 'Other Income','Sort Me (Inbound)') THEN t.value_usd ELSE 0 END) - SUM(CASE WHEN gh.top_category in ('Cost of Revenue','Expenses','Other Expenses','Sort Me (Outbound)') THEN t.value_usd ELSE 0 END) AS \"Net (incl. Unsorted)\"\nFROM general_ledger AS t\nJOIN group_hierarchy gh\n ON t.txgroup_id = gh.txgroup_id\nWHERE t.timestamp >= $__from/1000\n AND t.timestamp <= $__to/1000\nGROUP BY timestamp\nORDER BY timestamp;",
|
889
889
|
"queryType": "table",
|
890
|
-
"rawQueryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT\n txgroup_id,\n name AS top_category,\n parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n t.timestamp,\n SUM(CASE WHEN gh.top_category in ('Revenue', 'Other Income','Sort Me (Inbound)') THEN t.value_usd ELSE 0 END) AS \"Total Revenue (incl. Unsorted)\",\n SUM(CASE WHEN gh.top_category in ('Cost of Revenue','Expenses','Other Expenses','Sort Me (Outbound)') THEN t.value_usd ELSE 0 END) * -1 AS \"Total Expenses (incl. Unsorted)\",\n SUM(CASE WHEN gh.top_category in ('Revenue', 'Other Income','Sort Me (Inbound)') THEN t.value_usd ELSE 0 END) - SUM(CASE WHEN gh.top_category in ('Cost of Revenue','Expenses','Other Expenses','Sort Me (Outbound)') THEN t.value_usd ELSE 0 END) AS \"Net (incl. Unsorted)\"\nFROM
|
890
|
+
"rawQueryText": "WITH RECURSIVE group_hierarchy (txgroup_id, top_category, parent_txgroup) AS (\n SELECT\n txgroup_id,\n name AS top_category,\n parent_txgroup\n FROM txgroups\n WHERE parent_txgroup IS NULL\n\n UNION ALL\n\n SELECT\n child.txgroup_id,\n parent.top_category,\n child.parent_txgroup\n FROM txgroups AS child\n JOIN group_hierarchy AS parent\n ON child.parent_txgroup = parent.txgroup_id\n)\nSELECT\n t.timestamp,\n SUM(CASE WHEN gh.top_category in ('Revenue', 'Other Income','Sort Me (Inbound)') THEN t.value_usd ELSE 0 END) AS \"Total Revenue (incl. Unsorted)\",\n SUM(CASE WHEN gh.top_category in ('Cost of Revenue','Expenses','Other Expenses','Sort Me (Outbound)') THEN t.value_usd ELSE 0 END) * -1 AS \"Total Expenses (incl. Unsorted)\",\n SUM(CASE WHEN gh.top_category in ('Revenue', 'Other Income','Sort Me (Inbound)') THEN t.value_usd ELSE 0 END) - SUM(CASE WHEN gh.top_category in ('Cost of Revenue','Expenses','Other Expenses','Sort Me (Outbound)') THEN t.value_usd ELSE 0 END) AS \"Net (incl. Unsorted)\"\nFROM general_ledger AS t\nJOIN group_hierarchy gh\n ON t.txgroup_id = gh.txgroup_id\nWHERE t.timestamp >= $__from/1000\n AND t.timestamp <= $__to/1000\nGROUP BY timestamp\nORDER BY timestamp;",
|
891
891
|
"refId": "A",
|
892
892
|
"timeColumns": [
|
893
893
|
"timestamp"
|
@@ -1,33 +1,38 @@
|
|
1
1
|
"""This module contains utilities for managing dao-treasury's docker containers"""
|
2
2
|
|
3
3
|
import logging
|
4
|
-
import
|
4
|
+
from importlib import resources
|
5
5
|
import subprocess
|
6
6
|
from functools import wraps
|
7
|
-
from typing import Any, Callable, Coroutine, Final, Iterable, Tuple, TypeVar
|
7
|
+
from typing import Any, Callable, Coroutine, Final, Iterable, Tuple, TypeVar, List
|
8
8
|
|
9
9
|
import eth_portfolio_scripts.docker
|
10
10
|
from typing_extensions import ParamSpec
|
11
11
|
|
12
12
|
logger: Final = logging.getLogger(__name__)
|
13
13
|
|
14
|
-
compose_file: Final =
|
15
|
-
|
14
|
+
compose_file: Final = str(
|
15
|
+
resources.files("dao_treasury").joinpath("docker-compose.yaml")
|
16
16
|
)
|
17
17
|
"""The path of dao-treasury's docker-compose.yaml file on your machine"""
|
18
18
|
|
19
19
|
|
20
|
-
def up() -> None:
|
21
|
-
"""Build and start
|
20
|
+
def up(*services: str) -> None:
|
21
|
+
"""Build and start the specified containers defined in the compose file.
|
22
|
+
|
23
|
+
Args:
|
24
|
+
services: service names to bring up.
|
22
25
|
|
23
26
|
This function first builds the Docker services by invoking
|
24
|
-
:func:`build` and then starts
|
27
|
+
:func:`build` and then starts the specified services in detached mode using
|
25
28
|
Docker Compose. If Docker Compose is not available, it falls back
|
26
29
|
to the legacy ``docker-compose`` command.
|
27
30
|
|
28
31
|
Examples:
|
32
|
+
>>> up('grafana')
|
33
|
+
starting the grafana container
|
29
34
|
>>> up()
|
30
|
-
starting
|
35
|
+
starting all containers (grafana and renderer)
|
31
36
|
|
32
37
|
See Also:
|
33
38
|
:func:`build`
|
@@ -35,10 +40,10 @@ def up() -> None:
|
|
35
40
|
:func:`_exec_command`
|
36
41
|
"""
|
37
42
|
# eth-portfolio containers must be started first so dao-treasury can attach to the eth-portfolio docker network
|
38
|
-
eth_portfolio_scripts.docker.up()
|
39
|
-
build()
|
40
|
-
print("starting the grafana
|
41
|
-
_exec_command(["up", "-d"])
|
43
|
+
eth_portfolio_scripts.docker.up("victoria-metrics")
|
44
|
+
build(*services)
|
45
|
+
print(f"starting the {', '.join(services) if services else 'grafana'} container(s)")
|
46
|
+
_exec_command(["up", "-d", *services])
|
42
47
|
|
43
48
|
|
44
49
|
def down() -> None:
|
@@ -57,7 +62,7 @@ def down() -> None:
|
|
57
62
|
_exec_command(["down"])
|
58
63
|
|
59
64
|
|
60
|
-
def build() -> None:
|
65
|
+
def build(*services: str) -> None:
|
61
66
|
"""Build Docker images for Grafana containers.
|
62
67
|
|
63
68
|
This function builds all services defined in the Docker Compose
|
@@ -73,7 +78,7 @@ def build() -> None:
|
|
73
78
|
:func:`_exec_command`
|
74
79
|
"""
|
75
80
|
print("building the grafana containers")
|
76
|
-
_exec_command(["build"])
|
81
|
+
_exec_command(["build", *services])
|
77
82
|
|
78
83
|
|
79
84
|
_P = ParamSpec("_P")
|
@@ -118,20 +123,20 @@ def ensure_containers(
|
|
118
123
|
# signal.signal(signal.SIGINT, down)
|
119
124
|
|
120
125
|
# start Grafana containers
|
121
|
-
up()
|
126
|
+
up("grafana")
|
122
127
|
|
123
128
|
try:
|
124
129
|
# attempt to run `fn`
|
125
|
-
await fn(*args, **kwargs)
|
130
|
+
return await fn(*args, **kwargs)
|
126
131
|
finally:
|
127
132
|
# stop and remove containers
|
128
133
|
# down()
|
129
|
-
|
134
|
+
pass
|
130
135
|
|
131
136
|
return compose_wrap
|
132
137
|
|
133
138
|
|
134
|
-
def _exec_command(command:
|
139
|
+
def _exec_command(command: List[str], *, compose_options: Tuple[str, ...] = ()) -> None:
|
135
140
|
"""Execute a Docker Compose command with system checks and fallback.
|
136
141
|
|
137
142
|
This internal function ensures that Docker and Docker Compose
|