Skip to content

Commit

Permalink
Merge pull request #20 from shuva10v/main
Browse files Browse the repository at this point in the history
Adding icons
  • Loading branch information
shuva10v authored Jun 14, 2024
2 parents 844dd62 + 8d6b498 commit 0e24b2a
Show file tree
Hide file tree
Showing 141 changed files with 323 additions and 10 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.7]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run Tests
run: |
python validate.py test
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ must contain all possible interactions and unique off-chain analytics tag.
scoring formula, etc..
* [ScoreModel](./models/scores.py) - final formula to get scores for each project based on metrics

Every project must have an icon, icon must be present in the [projects/icons](projects/icons) folder.
Icon name template is ``{leaderboard}_{project_name}.{extension}``, where:
* __leaderboard__ - value from ``SeasonConfig.leaderboard``
* __project_name__ - project name (``Project.name``), in lower-case
* __extension__ - svg or png. In case of png size must be 100x100 px.

## Season

List of the seasons supported with the leaderboard links
Expand Down
16 changes: 16 additions & 0 deletions models/icons.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import glob
import os

from models.season_config import SeasonConfig


def get_icon_name(config: SeasonConfig, project: any):
# start with detecing icon extension
prefix = config.leaderboard + "_" + project.name.lower()
icons = glob.glob(f"{os.path.dirname(os.path.realpath(__file__))}/../projects/icons/{prefix}.*")
if len(icons) == 0:
raise Exception(f"No icon found for {project.name}")
if len(icons) > 1:
raise Exception(f"Multiple icon formats found for {project.name}")
format = icons[0].split(".")[-1]
return prefix + '.' + format
33 changes: 26 additions & 7 deletions models/render_method.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import glob
import os
from decimal import Decimal

import pandas as pd
import time
from datetime import datetime

from models.results import CalculationResults
from models.icons import get_icon_name
from models.results import CalculationResults, ProjectStat
import json
import pathlib
import git
Expand All @@ -15,19 +18,32 @@
Method to render results
"""
class RenderMethod:
def __init__(self, icons_base_path):
self.icons_base_path = icons_base_path

def render(self, res: CalculationResults, config: SeasonConfig):
raise NotImplemented()

def get_commit_hash(self):
repo = git.Repo(search_parent_directories=True, path=pathlib.Path(__file__).parent.resolve())
return repo.head.object.hexsha

def get_items(self, res: CalculationResults):
def get_icon(self, project: ProjectStat, config: SeasonConfig):
icon_name = get_icon_name(config, project)
if self.icons_base_path:
return self.icons_base_path + icon_name
else:
return icon_name



def get_items(self, res: CalculationResults, config: SeasonConfig):
items = []
for item in res.ranking:
obj = {
'name': item.name,
'score': item.score
'score': item.score,
'icon': self.get_icon(item, config)
}
for k, v in item.metrics.items():
obj[k] = float(v) if type(v) == Decimal else v
Expand All @@ -36,11 +52,13 @@ def get_items(self, res: CalculationResults):


class JsonRenderMethod(RenderMethod):
def __init__(self, output_name):

def __init__(self, output_name, icons_base_path=None):
RenderMethod.__init__(self, icons_base_path)
self.output_name = output_name

def render(self, res: CalculationResults, config: SeasonConfig):
items = self.get_items(res)
items = self.get_items(res, config)
res = {
'update_time': res.build_time,
'build_time': int(time.time()),
Expand All @@ -52,11 +70,12 @@ def render(self, res: CalculationResults, config: SeasonConfig):
json.dump(res, out, indent=True)

class HTMLRenderMethod(RenderMethod):
def __init__(self, output_name):
def __init__(self, output_name, icons_base_path=None):
RenderMethod.__init__(self, icons_base_path)
self.output_name = output_name

def render(self, res: CalculationResults, config: SeasonConfig):
items = self.get_items(res)
items = self.get_items(res, config)
table = pd.DataFrame(items).to_html()
with open(self.output_name, "wt") as out:
out.write(f"<html><head>Results for {config.name}</head><body>")
Expand Down
Binary file added projects/icons/apps_arbuz.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added projects/icons/apps_catizen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added projects/icons/apps_cheques corp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added projects/icons/apps_chick coop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions projects/icons/apps_fanton.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions projects/icons/apps_fanzee.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added projects/icons/apps_gatto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions projects/icons/apps_getgems.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added projects/icons/apps_gm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions projects/icons/apps_gram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added projects/icons/apps_jetton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added projects/icons/apps_play wallet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added projects/icons/apps_playwallet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added projects/icons/apps_quackquack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added projects/icons/apps_shardify.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added projects/icons/apps_squidtg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added projects/icons/apps_swap.coffee.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added projects/icons/apps_tap fantasy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added projects/icons/apps_the pixels.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added projects/icons/apps_the royal fortress.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions projects/icons/apps_ton punks.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions projects/icons/apps_ton raffles.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added projects/icons/apps_tonano.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added projects/icons/apps_tongochi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added projects/icons/apps_tonsoffriends.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions projects/icons/apps_tonup.svg
Binary file added projects/icons/apps_xplus.png
Binary file added projects/icons/apps_xrare.png
Binary file added projects/icons/apps_yescoin.png
Binary file added projects/icons/defi_daolama.png
Loading

0 comments on commit 0e24b2a

Please sign in to comment.