From c21f557ed76b54f1992946b31af2fe1778b0319e Mon Sep 17 00:00:00 2001 From: Alexandre Teles Date: Sun, 26 Mar 2023 18:57:30 -0300 Subject: [PATCH] fix: fix count order --- .github/workflows/codeql_analysis.yml | 59 ---------------------- .github/workflows/dev.yml | 2 - .github/workflows/features.yml | 70 --------------------------- .github/workflows/main.yml | 2 - .github/workflows/mypy.yml | 26 ---------- .github/workflows/pull_requests.yml | 65 ------------------------- vote_count.py | 23 +++------ 7 files changed, 7 insertions(+), 240 deletions(-) delete mode 100644 .github/workflows/codeql_analysis.yml delete mode 100644 .github/workflows/features.yml delete mode 100644 .github/workflows/mypy.yml delete mode 100644 .github/workflows/pull_requests.yml diff --git a/.github/workflows/codeql_analysis.yml b/.github/workflows/codeql_analysis.yml deleted file mode 100644 index 886b57e..0000000 --- a/.github/workflows/codeql_analysis.yml +++ /dev/null @@ -1,59 +0,0 @@ -name: "CodeQL" - -on: - push: - branches: [ "dev" ] - pull_request: - branches: [ "dev" ] - schedule: - - cron: '21 13 * * 3' - workflow_dispatch: - -env: - default_branch: dev - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'python' ] - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - with: - ref: ${{ env.default_branch }} - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.10.8' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - if [ -f requirements.txt ]; - then pip install -r requirements.txt; - fi - echo "CODEQL_PYTHON=$(which python)" >> $GITHUB_ENV - - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - setup-python-dependencies: false - - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - with: - category: "/language:${{matrix.language}}" diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 35d507c..75f38e4 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -3,8 +3,6 @@ name: Build dev branch on: push: branches: [ "dev" ] - schedule: - - cron: '24 9 * * 6' workflow_dispatch: env: diff --git a/.github/workflows/features.yml b/.github/workflows/features.yml deleted file mode 100644 index cc6cb90..0000000 --- a/.github/workflows/features.yml +++ /dev/null @@ -1,70 +0,0 @@ -name: Build a feature branch - -on: - workflow_dispatch: - inputs: - branch: - description: 'Branch' - required: true - default: '' - -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} - IMAGE_TAG: ${{ github.sha }} - -jobs: - security_checks: - runs-on: ubuntu-latest - name: Security check - steps: - - uses: actions/checkout@v2 - - name: Security Checks (PyCharm Security) - uses: tonybaloney/pycharm-security@master - with: - path: . - - build: - needs: security_checks - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - - steps: - - name: Checkout Dockerfile - id: checkout - uses: actions/checkout@v3 - with: - ref: ${{ inputs.branch }} - - - name: Setup QEMU - id: qemu - uses: docker/setup-qemu-action@v1 - with: - image: tonistiigi/binfmt:latest - platforms: all - - - name: Setup Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v1 - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v3 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - flavor: | - latest=${{ startsWith(github.ref, 'refs/heads/main') }} - suffix=-${{ github.sha }} - - - name: Build Docker image - id: build - uses: docker/build-push-action@v2 - with: - context: . - file: ./Dockerfile - platforms: linux/amd64,linux/arm64/v8 - push: false - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9115554..49bb05a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,8 +3,6 @@ name: Build and Publish Docker Image on: push: branches: [ main ] - schedule: - - cron: '24 9 * * 6' workflow_dispatch: env: diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml deleted file mode 100644 index 7325444..0000000 --- a/.github/workflows/mypy.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: MyPy Type Checking - -on: - push: - paths: - - '*.py' - -jobs: - mypy: - runs-on: ubuntu-latest - steps: - - name: Setup Python - uses: actions/setup-python@v1 - with: - python-version: 3.10.8 - architecture: x64 - - name: Checkout - uses: actions/checkout@v1 - - name: Install mypy - run: pip install mypy - - name: Run mypy - uses: sasanquaneuf/mypy-github-action@releases/v1 - with: - checkName: 'mypy' - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml deleted file mode 100644 index c00b953..0000000 --- a/.github/workflows/pull_requests.yml +++ /dev/null @@ -1,65 +0,0 @@ -on: - pull_request: - branches: [ "main", "dev" ] - workflow_dispatch: - -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} - IMAGE_TAG: ${{ github.sha }} - -jobs: - security_checks: - runs-on: ubuntu-latest - name: Security check - steps: - - uses: actions/checkout@v2 - - name: Security Checks (PyCharm Security) - uses: tonybaloney/pycharm-security@master - with: - path: . - - build: - needs: security_checks - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - - steps: - - name: Checkout Dockerfile - id: checkout - uses: actions/checkout@v3 - with: - ref: ${{ inputs.branch }} - - - name: Setup QEMU - id: qemu - uses: docker/setup-qemu-action@v1 - with: - image: tonistiigi/binfmt:latest - platforms: all - - - name: Setup Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v1 - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v3 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - flavor: | - latest=${{ startsWith(github.ref, 'refs/heads/main') }} - suffix=-${{ github.sha }} - - - name: Build Docker image - id: build - uses: docker/build-push-action@v2 - with: - context: . - file: ./Dockerfile - platforms: linux/amd64,linux/arm64/v8 - push: false - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/vote_count.py b/vote_count.py index 1adcff8..c936b06 100644 --- a/vote_count.py +++ b/vote_count.py @@ -21,14 +21,9 @@ for key in db.scan_iter("*"): votes[entry["cid"]] = 1 raw_votes: str = pformat(votes) -sorted_votes: str = pformat(sorted(votes)) +sorted_votes: str = pformat(sorted(votes, key=votes.get, reverse=True)) -text: list = [ - 'Raw votes:\n\n', - raw_votes, - '\n\nSorted votes:\n\n', - sorted_votes -] +text: list = ["Raw votes:\n\n", raw_votes, "\n\nSorted votes:\n\n", sorted_votes] with open("votes.txt", "w") as f: f.writelines(text) @@ -36,22 +31,18 @@ with open("votes.txt", "w") as f: payload: dict = { "description": "ReVanced Poll Results", "sections": [ + {"name": "Raw Votes", "syntax": "autodetect", "contents": raw_votes}, { - "name": "Raw Votes", + "name": "Sorted Votes (higher first)", "syntax": "autodetect", - "contents": raw_votes + "contents": sorted_votes, }, - { - "name": "Sorted Votes", - "syntax": "autodetect", - "contents": sorted_votes - } - ] + ], } headers = { "Content-Type": "application/json", - "X-Auth-Token": os.environ["PASTE_EE_KEY"] + "X-Auth-Token": os.environ["PASTE_EE_KEY"], } response: dict = requests.post(paste_url, json=payload, headers=headers).json()