Skip to content

Commit

Permalink
Update dependencies and remove unused files
Browse files Browse the repository at this point in the history
  • Loading branch information
appujet committed Apr 14, 2024
1 parent 3b5c1f7 commit 42f560a
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 294 deletions.
22 changes: 13 additions & 9 deletions .github/workflows/main .yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Remove Duplicate Nodes
name: Update Nodes

on:
push:
Expand All @@ -15,21 +15,25 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
- name: Install Dependencies
run: pip install -r requirements.txt

run: |
poetry install
- name: Generate Prisma Client
run: |
poetry run prisma generate
- name: Run Python Script
run: python remove_duplicates.py
run: |
poetry run python update_nodes.py
- name: Commit Changes
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git add .
git diff-index --quiet HEAD || git commit -m "Remove duplicate nodes"
git diff-index --quiet HEAD || git commit -m "Update Nodes"
git push
34 changes: 0 additions & 34 deletions .github/workflows/nodes.yml

This file was deleted.

244 changes: 0 additions & 244 deletions main.py

This file was deleted.

17 changes: 12 additions & 5 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ datasource db {
}

model Node {
id String @id @default(cuid())
id String @id @default(cuid())
authorId String
host String
identifier String @unique
identifier String @unique
password String
port Int
restVersion String
secure Boolean
isConnected Boolean @default(false)
isConnected Boolean @default(false)
info Json?
author Json?
memory String?
Expand All @@ -31,6 +31,13 @@ model Node {
cpuCores Int?
uptime String?
cpu String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}

model Nodes {
id String @id @default(cuid())
nodes Json
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ requests = "^2.31.0"
asyncio = "^3.4.3"
prisma = "^0.13.1"
aiohttp = "^3.9.3"
js = "^1.0"


[build-system]
Expand Down
1 change: 0 additions & 1 deletion requirements.txt

This file was deleted.

21 changes: 20 additions & 1 deletion remove_duplicates.py → update_nodes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import json
from prisma import Prisma
import asyncio

# Function to remove duplicate nodes
def remove_duplicates(data):
Expand Down Expand Up @@ -40,4 +42,21 @@ def add_restVersion(data):

# Save data with restVersion added
with open('nodes.json', 'w') as f:
json.dump(data, f, indent=4)
json.dump(unique_data, f, indent=4)

# Update database with unique nodes
async def update_nodes(nodes):
prisma = Prisma()
await prisma.connect()
# delete all nodes
await prisma.nodes.delete_many()
# create new nodes
await prisma.nodes.create({
"data": {
"nodes": nodes
}
})
await prisma.disconnect()

# Call updateNodes with unique_data
asyncio.run(update_nodes(unique_data))

0 comments on commit 42f560a

Please sign in to comment.