Skip to content
This repository has been archived by the owner on Nov 16, 2024. It is now read-only.

20-incorporate-crse-and-reddit-feedback #25

Merged
merged 96 commits into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
c60a97d
clean branch
eccentricOrange May 3, 2022
cbfbf92
begin making schema
eccentricOrange May 3, 2022
60c4097
inline foriegn keys
eccentricOrange May 3, 2022
2180207
add constraints
eccentricOrange May 3, 2022
0f98c9c
Merge pull request #21 from eccentricOrange:crse-db-schema
eccentricOrange May 3, 2022
889b015
create regex file
eccentricOrange May 4, 2022
462f203
create regex tests
eccentricOrange May 4, 2022
e6cc22d
get weekday counts to a generator
eccentricOrange May 4, 2022
2ffd791
finish parse rewrite
eccentricOrange May 4, 2022
95c5732
rearrange
eccentricOrange May 4, 2022
6bf32b3
update main calculation algo
eccentricOrange May 5, 2022
27b1e6d
finish saving function
eccentricOrange May 5, 2022
d4beda7
format function yield
eccentricOrange May 5, 2022
935ebb7
code rto add, edit, or delete papers
eccentricOrange May 5, 2022
7d39197
finish add/remove udl strings
eccentricOrange May 5, 2022
082d516
add connection.close for DB
eccentricOrange May 5, 2022
2459d2c
validation using exceptions
eccentricOrange May 5, 2022
ba8be96
add data retreival funcs
eccentricOrange May 5, 2022
1cc4a33
custom exceptions
eccentricOrange May 5, 2022
f380269
exceptions in testing
eccentricOrange May 5, 2022
49c0c67
docstrings, formatting
eccentricOrange May 5, 2022
2526462
Merge pull request #22 from eccentricOrange:core-file
eccentricOrange May 5, 2022
238a186
create parsers
eccentricOrange May 5, 2022
b49f22b
colorama
eccentricOrange May 5, 2022
7ff8632
make some progress on CLI
eccentricOrange May 5, 2022
5fff007
some more progress
eccentricOrange May 6, 2022
18ab30b
completed cli?
eccentricOrange May 7, 2022
ea51afb
fin up to testing del udl
eccentricOrange May 7, 2022
82617ca
testing db complete
eccentricOrange May 7, 2022
aad3d29
finished lots of testing
eccentricOrange May 7, 2022
826ccdf
docstrnings, rm some regex
eccentricOrange May 7, 2022
c025315
bugfixes
eccentricOrange May 7, 2022
38686e6
sort
eccentricOrange May 7, 2022
5c529da
Merge pull request #23 from eccentricOrange/CLI-file
eccentricOrange May 8, 2022
de9736a
test_build
eccentricOrange May 8, 2022
4e08599
string/number error
eccentricOrange May 8, 2022
9f39b04
pip?
eccentricOrange May 8, 2022
ff8c6be
on array
eccentricOrange May 8, 2022
975dbb7
ubuntu version
eccentricOrange May 8, 2022
0273e87
try without setup python
eccentricOrange May 8, 2022
36ace70
different image
eccentricOrange May 8, 2022
91639bd
sqlite version
eccentricOrange May 8, 2022
97cf7c6
manual python
eccentricOrange May 8, 2022
19be09f
typo in OS
eccentricOrange May 8, 2022
21f16e0
sudo?
eccentricOrange May 8, 2022
53cd216
-y in install
eccentricOrange May 8, 2022
31ba4fd
silent
eccentricOrange May 8, 2022
588b973
wrong apt
eccentricOrange May 8, 2022
943c9d0
non_interactive?
eccentricOrange May 8, 2022
0c96e96
debian?
eccentricOrange May 8, 2022
987d5fd
install git
eccentricOrange May 8, 2022
4042137
pyenv abs
eccentricOrange May 8, 2022
e8a40ac
checkout
eccentricOrange May 8, 2022
0e0574b
checkout later
eccentricOrange May 8, 2022
1890491
try as root
eccentricOrange May 8, 2022
0a22f6b
run/uses action
eccentricOrange May 8, 2022
9208b51
try with upgrade
eccentricOrange May 8, 2022
682c71b
-y in upgrade
eccentricOrange May 8, 2022
ba6f8b2
get versions
eccentricOrange May 8, 2022
133a95d
get sqlite
eccentricOrange May 8, 2022
4ab28ce
get detail
eccentricOrange May 8, 2022
5de39ac
different python
eccentricOrange May 8, 2022
8ff3ae3
recent ubuntu
eccentricOrange May 9, 2022
c6d633d
make and install sqlite
eccentricOrange May 9, 2022
c447f20
tar
eccentricOrange May 9, 2022
df690a7
retry
eccentricOrange May 9, 2022
9e04ad8
dirs
eccentricOrange May 9, 2022
852b86d
try abs
eccentricOrange May 9, 2022
37a14fc
try cd again
eccentricOrange May 9, 2022
445fada
cd typo
eccentricOrange May 9, 2022
e8ad9fd
list all
eccentricOrange May 9, 2022
091cbd2
working dir
eccentricOrange May 9, 2022
cf0a14e
try new
eccentricOrange May 9, 2022
fa6f116
sudo
eccentricOrange May 9, 2022
1f1f819
try change query to specify table
eccentricOrange May 9, 2022
cf47956
linker path
eccentricOrange May 9, 2022
2ededac
env
eccentricOrange May 9, 2022
0012228
env
eccentricOrange May 9, 2022
c2898b3
rm unnecessary envs
eccentricOrange May 9, 2022
8c5cab4
build windows
eccentricOrange May 9, 2022
fb7e6af
. issue
eccentricOrange May 9, 2022
a5a3239
temp faster
eccentricOrange May 9, 2022
408fd39
try .exe
eccentricOrange May 9, 2022
eeed929
all?
eccentricOrange May 9, 2022
dbf63c5
separate
eccentricOrange May 9, 2022
6baa31f
introduce linux and macos
eccentricOrange May 9, 2022
9b813cb
cleanup
eccentricOrange May 9, 2022
a106319
step error
eccentricOrange May 9, 2022
15ed95c
gz name
eccentricOrange May 9, 2022
f6f2f97
run release + needs
eccentricOrange May 9, 2022
077d1e2
reconfigure pyinstaller
eccentricOrange May 9, 2022
b41f2d7
delete old workflows
eccentricOrange May 9, 2022
4dcc9de
Merge pull request #24 from eccentricOrange:ci-cd-errors
eccentricOrange May 9, 2022
08be4f8
gitignore rules changed
eccentricOrange May 9, 2022
0e6b2f9
remove unnecessary env variable
eccentricOrange May 9, 2022
5fc3277
add comments
eccentricOrange May 9, 2022
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
75 changes: 0 additions & 75 deletions .github/workflows/build.yml

This file was deleted.

162 changes: 162 additions & 0 deletions .github/workflows/test-build-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
name: Test, build and release

on: [push]

jobs:

# test with pytest
test:
name: pytest
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

# build SQLite from source, because I need 3.35<=
- run: |
wget https://sqlite.org/2022/sqlite-autoconf-3380500.tar.gz
tar -xvf sqlite-autoconf-3380500.tar.gz
- run: |
./configure
make
sudo make install
export PATH="/usr/local/lib:$PATH"
working-directory: sqlite-autoconf-3380500

# run pytest
- uses: actions/setup-python@v2
with:
python-version: '3.10'
- run: pip install -r requirements.txt pytest
- run: pytest
env:
LD_LIBRARY_PATH: /usr/local/lib

# 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

# create release from tag
release:

# ensure that build is complete for all platforms
needs:
- build-linux
- build-macos
- build-windows

# run only if we're on a tag beginning with 'v' ('v1.2.5', for example)
if: startsWith(github.ref, 'refs/tags/v')

runs-on: ubuntu-latest
permissions:
contents: write

steps:

# download the artifacts
- run: mkdir bin
- uses: actions/download-artifact@v2
with:
path: bin

# do the release
- uses: ncipollo/release-action@v1
with:
artifacts: "bin/npbc*/*"
token: ${{ secrets.GITHUB_TOKEN }}
generateReleaseNotes: true
artifactErrorsFailBuild: true
prerelease: false
11 changes: 7 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ __pycache__
*build
*dist
.vs
exp
exp*
*legacy*
npbc.db
pyenv-install
bin
.vscode
.vscode
.pytest_cache
data/*
!data/test.sql
!data/schema.sql
.env
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This app calculates your monthly newspaper bill.
2. Each newspaper may or may not be delivered on a given day
3. Each newspaper has a name, and a number called a key
4. You may register any dates when you didn't receive a paper in advance using the `addudl` command
5. Once you calculate, the results are displayed and copied to your clipboard
5. Once you calculate, the results are displayed and logged.

## Installation
1. From [the latest release](https://github.com/eccentricOrange/npbc/releases/latest), download the "updater" file for your operating system in any folder, and make it executable.
Expand Down
65 changes: 40 additions & 25 deletions data/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,51 @@ CREATE TABLE IF NOT EXISTS papers (
name TEXT NOT NULL,
CONSTRAINT unique_paper_name UNIQUE (name)
);
CREATE TABLE IF NOT EXISTS papers_days_delivered (
paper_id INTEGER NOT NULL,

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,
delivered INTEGER NOT NULL,
FOREIGN KEY(paper_id) REFERENCES papers(paper_id),
CONSTRAINT unique_paper_day UNIQUE (paper_id, day_id)
);
CREATE TABLE IF NOT EXISTS papers_days_cost(
paper_id INTEGER NOT NULL,
day_id INTEGER NOT NULL,
cost INTEGER,
FOREIGN KEY(paper_id) REFERENCES papers(paper_id),
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
);

CREATE TABLE IF NOT EXISTS undelivered_strings (
entry_id INTEGER PRIMARY KEY AUTOINCREMENT,
year INTEGER NOT NULL,
month INTEGER NOT NULL,
paper_id INTEGER NOT NULL,
string TEXT NOT NULL,
FOREIGN KEY (paper_id) REFERENCES papers(paper_id)
string_id INTEGER PRIMARY KEY AUTOINCREMENT,
year INTEGER NOT NULL CHECK (year >= 0),
month INTEGER NOT NULL CHECK (month >= 0 AND month <= 12),
paper_id INTEGER NOT NULL REFERENCES papers(paper_id),
string TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS undelivered_dates (
entry_id INTEGER PRIMARY KEY AUTOINCREMENT,

CREATE TABLE IF NOT EXISTS logs (
log_id INTEGER PRIMARY KEY AUTOINCREMENT,
paper_id INTEGER NOT NULL REFERENCES papers(paper_id),
timestamp TEXT NOT NULL,
year INTEGER NOT NULL,
month INTEGER NOT NULL,
paper_id INTEGER NOT NULL,
dates TEXT NOT NULL,
FOREIGN KEY (paper_id) REFERENCES papers(paper_id)
month INTEGER NOT NULL CHECK (month >= 0 AND month <= 12),
year INTEGER NOT NULL CHECK (year >= 0),
CONSTRAINT unique_log UNIQUE (timestamp, paper_id, month, year)
);

CREATE TABLE IF NOT EXISTS undelivered_dates_logs (
undelivered_dates_log_id INTEGER PRIMARY KEY AUTOINCREMENT,
log_id INTEGER NOT NULL REFERENCES logs(log_id),
date_not_delivered TEXT NOT NULL
);
CREATE INDEX IF NOT EXISTS search_strings ON undelivered_strings(year, month);
CREATE INDEX IF NOT EXISTS paper_names ON papers(name);

CREATE TABLE IF NOT EXISTS cost_logs (
cost_log_id INTEGER PRIMARY KEY AUTOINCREMENT,
log_id INTEGER NOT NULL REFERENCES logs(log_id),
cost REAL NOT NULL
);
31 changes: 31 additions & 0 deletions data/test.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
INSERT INTO papers (name)
VALUES
('paper1'),
('paper2'),
('paper3');

INSERT INTO papers_days (paper_id, day_id)
VALUES
(1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6),
(2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6),
(3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6);

INSERT INTO papers_days_delivered (paper_day_id, delivered)
VALUES
(01, 0), (02, 1), (03, 0), (04, 0), (05, 0), (06, 1), (07, 1),
(08, 0), (09, 0), (10, 0), (11, 0), (12, 1), (13, 0), (14, 1),
(15, 1), (16, 1), (17, 0), (18, 0), (19, 1), (20, 1), (21, 1);

INSERT INTO papers_days_cost (paper_day_id, cost)
VALUES
(01, 0.0), (02, 6.4), (03, 0.0), (04, 0.0), (05, 0.0), (06, 7.9), (07, 4.0),
(08, 0.0), (09, 0.0), (10, 0.0), (11, 0.0), (12, 3.4), (13, 0.0), (14, 8.4),
(15, 2.4), (16, 4.6), (17, 0.0), (18, 0.0), (19, 3.4), (20, 4.6), (21, 6.0);

INSERT INTO undelivered_strings (year, month, paper_id, string)
VALUES
(2020, 11, 1, '5'),
(2020, 11, 1, '6-12'),
(2020, 11, 2, 'sundays'),
(2020, 11, 3, '2-tuesday'),
(2020, 10, 3, 'all');
Loading