mimblewimble / grin-explorer

Blockchain explorer for grin
GNU Affero General Public License v3.0
59 stars 52 forks source link

Strange Blocks And Total Difficulty Graph #51

Closed quentinlesceller closed 4 years ago

quentinlesceller commented 4 years ago

On our explorer https://www.grinmint.com/explorer/ we have this graph. Which doesn't looks like https://grinexplorer.net and I'm assuming that's why the page takes a very long time to load. Is there a specific configuration to reduce the range (or have something that looks like what you have @hendi)?

hendi commented 4 years ago

I have it limited to the last 30 days:

index d6a8471..50a509c 100644
--- a/grinexplorer/explorer/views.py
+++ b/grinexplorer/explorer/views.py
@@ -25,8 +25,8 @@ class BlockList(ListView):
             data = Block.objects.raw("select 1 as hash, to_char(timestamp,'MM-dd') as niceday, "
                                      "max(total_difficulty) as total_difficulty, "
                                      "date(DATE_TRUNC('day', timestamp)) as date, count(hash) as num "
-                                     "from blockchain_block "
+                                     "from blockchain_block where timestamp > current_date - interval '30 day'"
             cache.set(key, data, 60*5)

         blockpivotdata = DataPool(
@@ -131,7 +131,7 @@ class BlockList(ListView):
             data = Block.objects.raw("select 1 as hash, to_char(timestamp,'MM-dd') as niceday, "
                                      "date(DATE_TRUNC('day', timestamp)) as date, sum(fee)/1000000 as fee "
                                      "from blockchain_block t1 join blockchain_kernel t2 "
-                                     "on t2.block_id=t1.hash "
+                                     "on t2.block_id=t1.hash where timestamp > current_date - interval '30 day' "
                                      "group by DATE_TRUNC('day', timestamp),niceday order by date")
             cache.set(key, data, 60*5)
quentinlesceller commented 4 years ago

Great I think that should probably be the default too. Going to open a PR for that.