-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make it so that streak.json
and Extraordinary. MD
do not have duplicate entry for same account.
#87
Comments
I'd Like to know more |
This repo can be used multiple time for same account and each time it will add to open further rank for Pair-Extraordinaire badge. But for each time there will be a separate entry for same person in Basically what I want to do is if a user decide to reuse the repo it does do all the steps, but while updating the |
GitHub Copilot: Sure, here's a step-by-step plan in pseudocode:
Here's a Python code snippet that implements the above pseudocode: import json
def update_files(user, entry):
# Open the streak.json file and read its content
with open('streak.json', 'r+') as file:
data = json.load(file)
# Check if the user's account is in the JSON object
if user in data:
# Add a new entry to the block
data[user].append(entry)
else:
# Add a new block for the user
data[user] = [entry]
# Write the string back to the streak.json file
file.seek(0)
json.dump(data, file)
file.truncate()
# Repeat similar steps for the Extraordinary.md file
with open('Extraordinary.md', 'r+') as file:
content = file.readlines()
# Check if the user's account is in the file
if any(user in line for line in content):
# Add a new entry to the user's line
for i, line in enumerate(content):
if user in line:
content[i] += '\n' + entry
break
else:
# Add a new line for the user
content.append(user + '\n' + entry)
# Write the content back to the Extraordinary.md file
file.seek(0)
file.writelines(content)
file.truncate() You can call the update_files('user_account', 'new_entry') This code assumes that the import json def update_files(user, entry):
|
i used my subscription to to copilot for tis code, let me know what you think |
Hey, please test the code on your end by forking the repo and doing the suggested changes, I also have copilot subscription but this code will most likely not work. The streak.json is multilevel nested dict and we need to update extraordinary.md file too. Also if you are new to coding, I would suggest not using the copilot. As it will hinder in your skill development. I know how to do the changes for the issue, I am just not getting enough time to do this. |
OK Thanks, for your advice, yes i am new to coding and enjoying it very much, i work in IT but don't get to code so I'm teaching myself, i've forked the repo |
Yeah, Please familiarize yourself with code first. Use the README.md and provided graphs in documentation to understand the workflow. Then it will be much easier to do the changes. |
Although we can add an extra field in json "Times" to show how many times user has used the repo. Same can be done with Extraordinary.MD
The text was updated successfully, but these errors were encountered: