Giter Club home page Giter Club logo

npbc's Introduction

๐Ÿ‘‹ Hi, I'm a college student that loves robotics, and is currently studying Electrical Engineering at the Bachelor's level. Almost all projects uploaded here are something I've needed in real life.

Check out my personal blog: https://eccentricorange.netlify.app/ [repo]

  • I work with: Python, C++ (Arduino, ESP32), LabVIEW (myRIO FPGA, Desktop), KiCAD (PCB designing), physical electronics
  • Currently exploring: STM32 and ESP32 embedded C dev, RTOS, ROS2, PCB Designing
  • Learning about: core electrical/electronics, control systems, power electronics, kinematics, localization
  • Want to learn: core CS (architectures, OS, DSA, scaling, virtualization), the wizard-like skills old electrical engineers have
  • Other random skills: Git, Docker, Linux, CI+CD, Raspberry Pi, soldering, PCB designing, technical documentation
  • Random interests: articulately-written science-fiction, music production, OS-level vulnerabilities, intersection of quantum mechanics and astrophysics, table tennis, cool algorithms

profile for eccentricOrange on Stack Exchange, a network of free, community-driven Q&A sites

npbc's People

Contributors

eccentricorange avatar

Stargazers

 avatar  avatar

Watchers

 avatar

npbc's Issues

Better testing

Add better testing for the entire program.

  • Test creation of database if it does not exist.
  • Test the CLI.

Builds run unnecessarily

# build executable for linux
build-linux:
name: build for linux
runs-on: ubuntu-latest
needs: test
steps:
# setup
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- run: |
pip install pyinstaller
mkdir bin
mkdir build
# build
- run: |
pyinstaller --distpath bin --clean --onefile --name npbc_updater-linux-x64 npbc_updater.py
pip install -r requirements.txt
pyinstaller --distpath bin --clean --add-data "data/schema.sql:." --onefile --name npbc_cli-linux-x64 npbc_cli.py
# upload artifacts
- uses: actions/upload-artifact@v2
with:
path: bin
name: npbc_cli-linux-x64
- uses: actions/upload-artifact@v2
with:
path: bin
name: npbc_updater-linux-x64
# build executable for windows
build-windows:
name: build for windows
runs-on: windows-latest
needs: test
steps:
# setup
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- run: |
pip install pyinstaller
mkdir bin
mkdir build
# build
- run: |
pyinstaller --distpath bin --clean --onefile --name npbc_updater-windows-x64 npbc_updater.py
pip install -r requirements.txt
pyinstaller --distpath bin --clean --add-data "data/schema.sql;." --onefile --name npbc_cli-windows-x64 npbc_cli.py
# upload artifacts
- uses: actions/upload-artifact@v2
with:
path: bin
name: npbc_cli-windows-x64
- uses: actions/upload-artifact@v2
with:
path: bin
name: npbc_updater-windows-x64
# build executable for macos
build-macos:
name: build for macos
runs-on: macos-latest
needs: test
steps:
# setup
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- run: |
pip install pyinstaller
mkdir bin
mkdir build
# build
- run: |
pyinstaller --distpath bin --clean --onefile --name npbc_updater-macos-x64 npbc_updater.py
pip install -r requirements.txt
pyinstaller --distpath bin --clean --add-data "data/schema.sql:." --onefile --name npbc_cli-macos-x64 npbc_cli.py
# upload artifacts
- uses: actions/upload-artifact@v2
with:
path: bin
name: npbc_cli-macos-x64
- uses: actions/upload-artifact@v2
with:
path: bin
name: npbc_updater-macos-x64

Figure out a better alternative or method for the "installation"

Python applications are typically not distributed like EXEs (as an app written in C or something might be). They're typically distributed as source and an environment (or specifications thereof).

My hacky PyInstaller system is likely inefficient and not as portable.

Log row shown only if both fields present

The get_logged_data() function does not return some entries. It appears that it's showing only the entries for which an undelivered date and a cost both exist.

npbc/npbc_core.py

Lines 694 to 759 in 49dcf6e

def get_logged_data(
paper_id: int | None = None,
log_id: int | None = None,
month: int | None = None,
year: int | None = None,
timestamp: date_type | None = None
):
"""get logged data
- the user may specify as parameters many as they want
- available parameters: paper_id, log_id, month, year, timestamp
- returns: a list of tuples containing the following fields:
log_id, paper_id, month, year, timestamp, date, cost."""
global DATABASE_PATH
# initialize parameters for the WHERE clause of the SQL query
data = []
parameters = []
values = ()
# check each parameter and add it to the WHERE clause if it is given
if paper_id:
parameters.append("paper_id")
values += (paper_id,)
if log_id:
parameters.append("log_id")
values += (log_id,)
if month:
parameters.append("month")
values += (month,)
if year:
parameters.append("year")
values += (year,)
if timestamp:
parameters.append("timestamp")
values += (timestamp.strftime(r'%d/%m/%Y %I:%M:%S %p'),)
# generate the SQL query
columns_only_query = """
SELECT logs.log_id, logs.paper_id, logs.month, logs.year, logs.timestamp, undelivered_dates_logs.date_not_delivered, cost_logs.cost
FROM logs
INNER JOIN undelivered_dates_logs ON logs.log_id = undelivered_dates_logs.log_id
INNER JOIN cost_logs ON logs.log_id = cost_logs.log_id"""
if parameters:
conditions = ' AND '.join(
f"logs.{parameter} = ?"
for parameter in parameters
)
final_query = f"{columns_only_query} WHERE {conditions};"
else:
final_query = f"{columns_only_query};"
# execute the query
with connect(DATABASE_PATH) as connection:
data = connection.execute(final_query, values).fetchall()
connection.close()
return data

Redundancy in DB table `paper_day_id`

Consider the following section of the schema:

npbc/data/schema.sql

Lines 7 to 24 in 9d6eafb

CREATE TABLE IF NOT EXISTS papers_days (
paper_day_id INTEGER PRIMARY KEY AUTOINCREMENT,
paper_id INTEGER NOT NULL REFERENCES papers(paper_id),
day_id INTEGER NOT NULL,
CONSTRAINT unique_paper_day UNIQUE (paper_id, day_id)
);
CREATE TABLE IF NOT EXISTS papers_days_delivered (
papers_days_delivered_id INTEGER PRIMARY KEY AUTOINCREMENT,
paper_day_id INTEGER NOT NULL REFERENCES papers_days(paper_day_id),
delivered INTEGER NOT NULL CHECK (delivered IN (0, 1))
);
CREATE TABLE IF NOT EXISTS papers_days_cost (
papers_days_cost_id INTEGER PRIMARY KEY AUTOINCREMENT,
paper_day_id INTEGER NOT NULL REFERENCES papers_days(paper_day_id),
cost REAL
);

In practice

  • papers_days_delivered.papers_days_delivered is always equal to papers_days_delivered.paper_day_id
  • papers_days_cost.papers_days_cist_id is always equal to papers_days_cost.paper_day_id

In effect, this makes the primary key column redundant. More over, the data from the three tables mentioned here can be combined in to one effectively, without the kind of repetition prohibited by NF1.

Incorporate CRSE feedback 2

I had posted the code up to commit 041a949 to the Code Review Stack Exchange (abbreviated CRSE). Good feedback has been received, and will be acted up on.

Each comment tackles one file/aspect of the upgrades. The pull request immedeatly following a comment will have a summary of the changes and decisions made, with respect to the issue comment.

Incorporate CRSE and Reddit feedback

I had posted the code up to commit 6020a4f to the Code Review Stack Exchange (abbreviated CRSE). Good feedback has been received, and will be acted up on.

I had also posted up to commit 3250a1a to r/learnpython on Reddit, and got some good feedback there too.

Each comment tackles one file/aspect of the upgrades. The pull request immedeatly following a comment will have a summary of the changes and decisions made, with respect to the issue comment.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.