GithubHelp home page GithubHelp logo

albugowy15 / auto-frs-schedule Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 318 KB

Part of the Informatics FRS Helper project to automatically parse all class schedule from Excel files to MySQL database.

License: MIT License

Rust 100.00%
mysql rust tokio-rs clap-rs cli

auto-frs-schedule's Introduction

Auto FRS Schedule

Project Overview

This CLI application is a crucial part of the Informatics FRS Helper project, designed to facilitate data management within a MySQL database.

Supported Commands

  • update : Parses all class data from an Excel file and subsequently updates the MySQL database. Alternatively, it provides an option to save the parsed data to an SQL file.
  • compare : Compares the class schedule stored in the database with the latest data from an Excel file.
  • find : Retrieves all available schedules for a specific class.
  • sync : Synchronizes the taken field in the Class table and the totalSks field in the Plan table to reflect their current values.
  • clean : Removes any invalid foreign keys present in the _ClassToPlan and _ClassToLecturer tables.

Supported Arguments

update command

  • -p --push : An optional argument to specify whether only parsing the Excel file or also pushing the class data to the database.
  • -f --file : A required argument indicating the path to the Excel file.
  • -s --sheet : A required argument specifying the name of the Excel sheet.
  • -o --outdir : An optional argument to determine the output directory for saving the SQL statements.

compare command

  • -f --file : A required argument indicating the path to the Excel file.
  • -s --sheet : A required argument specifying the name of the Excel sheet.
  • -o --outdir : A required argument to define the output directory for writing the comparison results.

find command

  • -f --file : A required argument indicating the path to the Excel file.
  • -s --sheet : A required argument specifying the name of the Excel sheet.
  • -c --course : A required argument indicating the subject name of the class to find schedules for.

How To Run

  1. To be able to run this project, you need to have Rust installed on your computer. You can refer to the following article for instructions on how to install and configure Rust based on your operating system. Install Rust - Rust Programming Language.

  2. Next, clone this repository.

    git clone https://github.com/albugowy15/auto-frs-schedule.git
  3. Set the FRS_HELPER_DB_URL environment variable to store the MySQL database connection details.

  4. Navigate to the project's root directory and build the project using the following command:

    cargo build --release

    This command will create an optimized executable binary in the target/release directory.

  5. Copy or move the generated binary file to a directory included in your system's PATH environment variable. This allows you to run the application from any directory without specifying the full path.

    • On Linux and macOS, you can copy the binary to the /usr/local/bin directory, which is typically included in the PATH.
      sudo cp target/release/auto-frs-schedule /usr/local/bin/
    • On Windows, you can copy the binary to a directory already included in the PATH, such as C:\Windows\System32.
      copy target\release\auto-frs-schedule.exe C:\Windows\System32\
  6. After copying the binary to a directory in the PATH, you can open a new terminal or command prompt window and run the CLI application from anywhere by simply typing its name.

    auto-frs-schedule --version

Example

# Example 1: Parse and push class schedule to MySQL database
auto-frs-schedule update --push -f ~/Downloads/FRS.xlsx -s "Jadwal Kuliah"

Open FRS.xlsx file from the ~/Downloads directory, parse all class schedules from Jadwal Kuliah sheet, and push the data to the MySQL database.

# Example 2: Parse class schedule and save SQL statements to a file
auto-frs-schedule update -f ~/Downloads/FRS.xlsx -s "Jadwal Kuliah" -o ./result/classes.sql

Open the FRS.xlsx file from the ~/Downloads directory, parse all class schedules from the Jadwal Kuliah sheet, and save the SQL statements to the ./result/classes.sql file.

# Example 3: Parse, push to MySQL, and save SQL statements to a file
auto-frs-schedule update --push -f ~/Downloads/FRS.xlsx -s "Jadwal Kuliah" -o ./result/classes.sql

Open the FRS.xlsx file from the ~/Downloads directory, parse all class schedules from the Jadwal Kuliah sheet, push the data to the MySQL database, and save the SQL statements to the ./result/classes.sql file.

# Example 4: Compare class schedule and save changes to a file
auto-frs-schedule compare -f ~/Downloads/FRS.xlsx -s "Jadwal Kuliah" -o ./result/changes.txt

Open the FRS.xlsx file from the ~/Downloads directory, parse all class schedules from the Jadwal Kuliah sheet, compare it with the existing class schedule in the database, and save the changes to the ./result/changes.txt file.

# Example 5: Retrieve all schedules for the "Pemrograman Web" class
auto-frs-schedule find -f ~/Downloads/FRS.xlsx -s "Jadwal Kuliah" -c "Pemrograman Web"

Open the FRS.xlsx file from the ~/Downloads directory, parse all class schedules from the Jadwal Kuliah sheet, and retrieves all schedules for the "Pemrograman Web" class.

# Example 6: Update database fields to reflect current values
auto-frs-schedule sync

Update the taken field in the Class table and the totalSks field in the Plan table to reflect their current values.

# Example 7: Remove invalid foreign keys from tables
auto-frs-schedule clean

Remove any invalid foreign keys from the _ClassToPlan and _ClassToLecturer tables.

Libraries Used

  • calamine : Calamine stands as a purely Rust-based Excel/OpenDocument Spreadsheet file reader. Its support extends to various formats such as XLSX, XLS, ODS, and more, facilitating comprehensive file reading capabilities.
  • tokio : Tokio serves as a runtime designed for crafting reliable, asynchronous, and resource-efficient applications using the Rust programming language. It empowers the development of streamlined and high-performance applications.
  • sqlx : As a versatile Rust SQL Toolkit, sqlx offers asynchronous, pure Rust SQL functionality. Noteworthy features include compile-time checked queries, with support spanning PostgreSQL, MySQL, SQLite, and MSSQL databases.
  • clap : Clap emerges as a robust and swift Command Line Argument Parser for Rust. It facilitates the parsing of command-line arguments, enhancing the overall usability and flexibility of Rust applications.
  • indicatif : Indicatif contributes to the project by providing a set of utilities for indicating progress or status in the command line interface. This is particularly useful for conveying information about ongoing tasks or processes.
  • anyhow : Anyhow is employed for error handling in the project. It simplifies the process of handling various error types by providing a unified, ergonomic interface for error management in Rust applications.

auto-frs-schedule's People

Contributors

albugowy15 avatar github-actions[bot] avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

djiwandou

auto-frs-schedule's Issues

Compare existing schedule with the latest one

The comparation output will be a txt file with this format :

Added : 
Jaringan Komputer A
Organisasi Komputer B

Modified : 
Pemrograman Web B

Deleted : 
Perancangan dan Analisis Algoritma C - EN

Replace mysql_async with sqlx

mysql_async contribute 20% of project release binary. Cause the release binary reach 9.9 mb. The alternative is try using sqlx.

sync command

Sync command will sync current totalSks value in Plan and taken value in Class table with aggregate sum or count function that manually sum all the sks or taken from taken classes

Clean up command

Clean up command will delete some rows from _ClassToPlan and _ClassToLecturer table that no longer has valid foreign key.

Use only one sub command

There should be only one sub command for parse excel only and also insert to DB.

auto-frs-schedule --push -f <path-to-excel> -s <sheet-name> -o <output-directory> 
  • --push : Optional to determine wether only parse or also push class to DB
  • -o : Optional to write the sql statement to output directory
  • -f : Required for excel file path
  • -s : Required for excel sheet name

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.