Skip to content

Commit

Permalink
Merge branch 'main' into frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
g00gol committed Oct 8, 2023
2 parents 785f90f + c6be554 commit e9cccd3
Show file tree
Hide file tree
Showing 11 changed files with 2,558 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
backend/.env
*/target/
13 changes: 13 additions & 0 deletions backend/controllers/repos_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ func CreateRepo(w http.ResponseWriter, r *http.Request) {
repo.LastUpdated = utils.GetCurrentTime()
}


filter := utils.ConstructFilters(r, types.Repo{})

// Get data from database
data, err := db.GetReposByFilters(filter)
if err != nil {
log.Println(err)
}
if len(data) > 0 {
http.Error(w, "Error - duplicate entry", http.StatusBadRequest);
return
}

// Insert repo into database
_, err = db.GetCollection("repos").InsertOne(context.TODO(), repo)
if err != nil {
Expand Down
44 changes: 44 additions & 0 deletions frieren-cli/frieren-cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env python3

import os
import sys
import json
import git
import re
import requests

if __name__ == "__main__":
repo = git.Repo(os.getcwd(), search_parent_directories=True)
os.chdir(repo.git.rev_parse("--show-toplevel"))

origin = repo.remotes.origin.url[:-4]

try:
with open("open-source.fern", "r") as f:
fern = json.load(f)
except FileNotFoundError:
technologies = list(set(map(lambda x: x.strip(), input("Input technologies separated by a comma (','):").split(","))))
difficulty = -1
try:
difficulty = int(input("How difficult is your project to contribute to (1-5)? "))
if not 0 < difficulty < 6:
raise ValueError()
except ValueError as e:
raise ValueError("Error: difficulty should be a number from 1-5")

desc = input("Enter a brief description of your project: ")

recommended_issue_labels = list(set(map(lambda x: x.strip(), input("Input any tag/label that would be a good first issue separated by a comma (','):").split(","))))

fern = {"name": re.search(r"/([^/]*/[^/]*)$","https://github.com/g00gol/frieren").group(1), "technologies": technologies, "difficulty": difficulty, "description": desc, "recommended_issue_labels": recommended_issue_labels}

fern['repo_origin'] = origin

# Make api call
r = requests.post("http://127.0.0.1:8080/repos", json=fern)
if not 200 <= r.status_code < 300:
print("Error registering project")
else:
with open("open-source.fern", "w+") as f:
del fern['repo_origin']
json.dump(fern, f)
8 changes: 8 additions & 0 deletions frieren-cli/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
certifi==2023.7.22
charset-normalizer==3.3.0
gitdb==4.0.10
GitPython==3.1.37
idna==3.4
requests==2.31.0
smmap==5.0.1
urllib3==2.0.6
1 change: 1 addition & 0 deletions open-source.fern
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name": "g00gol/frieren", "technologies": ["MongoDB", "Rust", "Go", "Python", "JavaScript"], "difficulty": 3, "description": "Open source project finder", "recommended_issue_labels": ["easy", "start-here", "Good First Issue"]}
Loading

0 comments on commit e9cccd3

Please sign in to comment.