Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/checkcpp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: C/C++ CI

on:
push:
paths:
bubble.cpp
bubble.h
test_bubble.cpp
pull_request:
paths:
bubble.cpp
bubble.h
test_bubble.cpp

jobs:
Run_cpp:

runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Setup Compiler
run: sudo apt-get install g++

- name: Compile and Run Tests
run: |
g++ bubble.cpp test_bubble.cpp -o program
./program
- name: Report Test Status
run: |
if [[ $? -eq 0 ]]; then
echo "Tests passed."
else
echo "Tests failed."
exit 1
fi
33 changes: 33 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from flask import Flask
from flask import request
from flask import json
from gitQueue import addData

import redis
from rq import Queue

q = Queue(connection=redis.Redis())

app = Flask(__name__)


@app.route('/')
def home():
return 'Hello 🙂'


@app.route('/githubdata', methods=['POST'])
def apiMessage():

if request.headers['Content-Type'] == 'application/json':
job = q.enqueue(addData, json.dumps(request.json))

return json.dumps(request.json)

return "error"


if __name__ == '__main__':
app.run(debug=True)


8 changes: 8 additions & 0 deletions bubble.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// bubble.h
#ifndef BUBBLE_H
#define BUBBLE_H

// Declare the bubbleSort function
void bubbleSort(int arr[], int n);

#endif
19 changes: 19 additions & 0 deletions challenge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import json

def Pull_req():
return 10

def Round2(round):
if round == 21:
return 10

elif round == 22:
#analyse the sorting algo
return 10
return 0

def Round3(round):
if round == 31:
return 10
return 0

28 changes: 28 additions & 0 deletions dbms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import redis
from redis.commands.json.path import Path
import json

r = redis.Redis()

def updateUserScore(username,round,score):

if round ==11:
points = 10
elif round==21:
points = 20
elif round==22 and score!=0:
points = 30
elif round==31:
points = 40

if round != 11:
data = json.loads(r.get(username)) #deserializes into json format converts into dict
data['score'] = points
data['round'] = round
r.set(username,json.dumps(data)) #converts dict to json and updates the database

# else:

return 'success'


34 changes: 34 additions & 0 deletions gitQueue.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import json
from rounds import *
from challenge import *
from dbms import updateUserScore

def addData(request):
request=json.loads(request)
username=request['sender']['login']
round=Rounds(request)

status = 'none'

if round == 11:
score = Pull_req()
status = updateUserScore(username, round, score)
return status

elif round == 21:
score = Round2(round)
status = updateUserScore(username, round, score)
return status

elif round == 22:
score = Round2(round)
status = updateUserScore(username, round, score)
return status

elif round == 21:
score = Round2(round)
status = updateUserScore(username, round, score)
return status

return status

39 changes: 39 additions & 0 deletions rounds.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from flask import Flask
import json,requests

def riddle_ans(string):

return str(string.split('-')[1])



def check_forked(username,repo):
url = f"https;//github.com/{username}/{repo}" #username = glugmvit, repo = yet to be created
response = requests.get(url)

if response.status_code == 200:
data = response.json()
is_forked = data.get('fork', False)
return is_forked
print("error in check forked")
return False



def Rounds(request):

if 'forkee' in request.keys():
return 11

elif 'issue' in request.keys():
riddle_answer=[]
if riddle_ans(str(request['comment']['body'])) in riddle_answer:
return 21
else:
return 22 #pending {analyse the algo}

elif check_forked('glugmvit','repo'):
return 31



6 changes: 6 additions & 0 deletions send_req.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import requests

url = 'http://127.0.0.1:5000/githubdata'

r = requests.post(url)
print(r.content)
28 changes: 28 additions & 0 deletions test_bubble.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// test_bubble.cpp
#include <iostream>
#include "bubble.h"

int main() {
int arr[] = {5, 2, 8, 12, 3};
int n = sizeof(arr) / sizeof(arr[0]);

// Call your bubble sort function
bubbleSort(arr, n);

// Verify the sorted array
bool sorted = true;
for (int i = 1; i < n; ++i) {
if (arr[i] < arr[i - 1]) {
sorted = false;
break;
}
}

if (sorted) {
std::cout << "Test passed: Array is sorted." << std::endl;
return 0;
} else {
std::cerr << "Test failed: Array is not sorted." << std::endl;
return 1;
}
}