Skip to content

Round the number to nearest integer #104

@dadiorchen

Description

@dadiorchen

The two 1k here should be 1k and 2k.

    
      /* sql case1 tile */
      
      SELECT 
      'cluster' AS type,
      'case1 tile' AS log,
      NULL AS zoom_to,
      region_id id, 
      st_point(LEAST(st_x(centroid), 170), st_y(centroid)) estimated_geometric_location,St_asgeojson(st_point(LEAST(st_x(centroid), 170), st_y(centroid))) latlon,
      type_id as region_type,
      count(tree_region.id) count,
      CASE WHEN count(tree_region.id) > 1000 
      THEN  (count(tree_region.id) / 1000) || 'K'
      ELSE count(tree_region.id) || ''
      END AS count_text
      FROM active_tree_region tree_region
      JOIN trees ON tree_region.tree_id = trees.id
INNER JOIN wallet.token ON wallet.token.capture_id::text = trees.uuid 
INNER JOIN wallet.wallet ON wallet.wallet.id = wallet.token.wallet_id 

      WHERE zoom_level = 2
      AND wallet.wallet.name = 'heveya.replant.world'
      
      GROUP BY region_id, centroid, type_id

Result:

  type   |    log     | zoom_to |   id    |        estimated_geometric_location        |                           
latlon                            | region_type | count | count_text 
---------+------------+---------+---------+--------------------------------------------+---------------------------
----------------------------------+-------------+-------+------------
 cluster | case1 tile |         |   30286 | 010100000041BC1502E78052C0443F657A6F0B3240 | {"type":"Point","coordinat
es":[-74.014099618,18.044669771]} |           2 |     4 | 4
 cluster | case1 tile |         | 6632636 | 0101000000B0BB7ED6B7B43140AB29E99B3003E8BF | {"type":"Point","coordinat
es":[17.705930143,-0.75038939]}   |           9 |  1100 | 1K
 cluster | case1 tile |         | 6632644 | 010100000039ED9093A7BB5C402BBD034430D21240 | {"type":"Point","coordinat
es":[114.932103054,4.705262244]}  |           9 |  1896 | 1K

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions