Skip to content

Commit de2a599

Browse files
committed
Backend 🔚
1 parent 18d80f2 commit de2a599

16 files changed

Lines changed: 64 additions & 506 deletions

.github/workflows/backend_code_checker.yml

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,35 @@ on:
66
- backend/**
77
name: Backend Projects
88
jobs:
9-
githubuseractivity:
10-
name: githubuseractivity Code Checker
9+
TaskTracker:
10+
name: Task Tracker Code Checker
1111
runs-on: ubuntu-latest
1212
steps:
13-
- name: Cancel Previous Runs
14-
uses: styfle/cancel-workflow-action@0.9.1
13+
- uses: actions/checkout@v1
14+
- uses: ricardochaves/python-lint@master
1515
with:
16-
access_token: ${{ github.token }}
17-
- uses: actions/checkout@v2
18-
- name: Checking githubuseractivity
19-
working-directory: ./backend/githubuseractivity
20-
run: |
21-
chmod +x ./gradlew
22-
./gradlew build
16+
python-root-list: "backend/Task Tracker"
2317
- name: Send Message
2418
if: always()
2519
uses: appleboy/telegram-action@master
2620
with:
2721
to: ${{ secrets.TELEGRAM_TO }}
2822
token: ${{ secrets.TELEGRAM_TOKEN }}
2923
message: |
30-
GitHub Action for backend/githubuseractivity is completed with status ${{ job.status }} for ${{ github.ref }}.
31-
TaskTracker:
32-
name: Task Tracker Code Checker
24+
GitHub Action for backend/Task Tracker is completed with status ${{ job.status }} for ${{ github.ref }}.
25+
githubuseractivity:
26+
name: githubuseractivity Code Checker
3327
runs-on: ubuntu-latest
3428
steps:
3529
- uses: actions/checkout@v1
3630
- uses: ricardochaves/python-lint@master
3731
with:
38-
python-root-list: "backend/Task Tracker"
32+
python-root-list: "backend/githubuseractivity"
3933
- name: Send Message
4034
if: always()
4135
uses: appleboy/telegram-action@master
4236
with:
4337
to: ${{ secrets.TELEGRAM_TO }}
4438
token: ${{ secrets.TELEGRAM_TOKEN }}
4539
message: |
46-
GitHub Action for backend/Task Tracker is completed with status ${{ job.status }} for ${{ github.ref }}.
40+
GitHub Action for backend/githubuseractivity is completed with status ${{ job.status }} for ${{ github.ref }}.

backend/githubuseractivity/.gitignore

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,7 @@
1-
# githubuseractivity
1+
# Project Details
22

3-
This project was created using the [Ktor Project Generator](https://start.ktor.io).
3+
https://roadmap.sh/projects/github-user-activity
44

5-
Here are some useful links to get you started:
6-
7-
- [Ktor Documentation](https://ktor.io/docs/home.html)
8-
- [Ktor GitHub page](https://github.com/ktorio/ktor)
9-
- The [Ktor Slack chat](https://app.slack.com/client/T09229ZC6/C0A974TJ9). You'll need to [request an invite](https://surveys.jetbrains.com/s3/kotlin-slack-sign-up) to join.
10-
11-
## Features
12-
13-
Here's a list of features included in this project:
14-
15-
| Name | Description |
16-
| ----------------------------------------------------|------------------------------------------------------------- |
17-
| [Routing](https://start.ktor.io/p/routing-default) | Allows to define structured routes and associated handlers. |
18-
19-
## Building & Running
20-
21-
To build or run the project, use one of the following tasks:
22-
23-
| Task | Description |
24-
| -------------------------------|---------------------------------------------------------------------- |
25-
| `./gradlew test` | Run the tests |
26-
| `./gradlew build` | Build everything |
27-
| `buildFatJar` | Build an executable JAR of the server with all dependencies included |
28-
| `buildImage` | Build the docker image to use with the fat JAR |
29-
| `publishImageToLocalRegistry` | Publish the docker image locally |
30-
| `run` | Run the server |
31-
| `runDocker` | Run using the local docker image |
32-
33-
If the server starts successfully, you'll see the following output:
34-
35-
```
36-
2024-12-04 14:32:45.584 [main] INFO Application - Application started in 0.303 seconds.
37-
2024-12-04 14:32:45.682 [main] INFO Application - Responding at http://0.0.0.0:8080
38-
```
5+
# How to run?
396

7+
Use command `python3 github_user_activity.py <user-name>`

backend/githubuseractivity/build.gradle.kts

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import http.client
2+
import json
3+
import shlex
4+
import sys
5+
import subprocess
6+
7+
GITHUB_ACTIVITY_URL = "api.github.com/users"
8+
9+
def check_input():
10+
if len(sys.argv) > 1:
11+
return sys.argv[1]
12+
else:
13+
return None
14+
15+
def get_request(path):
16+
connection = http.client.HTTPSConnection("api.github.com")
17+
18+
try:
19+
cmd = "curl -L " \
20+
"-H \"Accept: application/vnd.github+json\" " \
21+
"-H \"Authorization: Bearer <USER_TOKEN>\" " \
22+
"-H \"X-GitHub-Api-Version: 2022-11-28\" " \
23+
"https://api.github.com/users/pradyotprksh/events"
24+
args = shlex.split(cmd)
25+
process = subprocess.Popen(args, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
26+
stdout, stderr = process.communicate()
27+
events = json.loads(stdout)
28+
return events
29+
except Exception as e:
30+
print(f'Exception occurred: {e}')
31+
finally:
32+
connection.close()
33+
34+
def get_user_activity(username):
35+
user_activity = get_request(f"/users/{username}/events")
36+
37+
if user_activity is None:
38+
print("Not able to get user activity. Check the username or try again.")
39+
return
40+
41+
for activity in user_activity:
42+
print(f"{activity["type"]} {activity["repo"]["name"]}")
43+
44+
if __name__ == '__main__':
45+
username = check_input()
46+
47+
if username is None:
48+
print("Please provide an username")
49+
else:
50+
get_user_activity(username)

backend/githubuseractivity/gradle.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.

backend/githubuseractivity/gradle/libs.versions.toml

Lines changed: 0 additions & 17 deletions
This file was deleted.
-58.1 KB
Binary file not shown.

backend/githubuseractivity/gradle/wrapper/gradle-wrapper.properties

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)