Giter VIP home page Giter VIP logo

jdt-generator's Introduction

jdt-generator - by Azecko

jdt-generator is a project created for the EPFL ISAS-FSD team to generate their weekly report directly without even thinking about it.

How to use

  1. Clone this repository
  2. Move in this new repository using the command cd jdt-generator
  3. Run npm i (this will create a folder named node_modules and install all the dependencies)
  4. Rename the file .env.example in .env
  5. Replace the variables in .env with your variables (explained below)
  6. Run the different Commands available

.env variables

DOC_ID

DOC_ID is the document id of your google spreadsheet file.
You can find it in the URL when opening your file on Google.
Example : https://docs.google.com/spreadsheets/d/1gZUSyHdif9KVEUAP1_445dCbyitvc7HMpbu9SM-C_BB

JSON_ENV_PATH

This one is the path to a file generated by Google.
Follow those steps to generate this file.
Thanks to the documentation of google-spreadsheet !

  1. Go to the Google Developers Console
  2. Select your project or create a new one (and then select it)
  3. Enable the sheets API for your project
  • In the sidebar on the left, select APIs & Services > Library
  • Search for "sheets"
  • Click on "Google Sheets API"
  • Click the "Enable" button
  1. Create a service account for your project
  • In the sidebar on the left, select APIs & Services > Credentials
  • Click the blue "+ CREATE CREDENTIALS" button and select the "Service account" option
  • Enter the name and description and click "CREATE"
  • You can skip permissions, click "CONTINUE"
  • Click the "+ CREATE KEY" button
  • Select the "JSON" key type option
  • Click the "Create" button
  • Your JSON key file is generated and downloaded to your machine (it's the only copy !)
  • Click "DONE"
  1. And then you can put the PATH to the downloaded file in the .env
  2. Don't forget to share the spreadsheet document with the e-mail that is in the JSON file ! The email should look something like [email protected]

SMTP_HOST

The link of your email server. Example : yourhost.mail.com

PORT

The port that will be used by the SMTP server.

AUTH_USER & AUTH_PASSWORD

Those are the username and password that you use to connect to the SMTP server.

Commands

All commands need at least two required option. from and to
They both take Date as value as format : YYYY-MM-DD
Example : --from=2022-01-01 --to=2022-12-31

md (markdown)

This command will log the MarkDown format of the JDT.
Usage : node index.js md --from=2022-01-01 --to=2022-12-31
If you want to have the result in a file and not just in the console, add > my_report.md at the end of the command. This will put the result of the console in a markdown file. node index.js md --from=2022-01-01 --to=2022-12-31 > my_report.md

email

This command will send the generated JDT by email to one or multiple email adresses. Usage example : node index.js email --from=2022-01-01 --to=2022-12-31 --receiver="[email protected], [email protected]" --subject="My weekly report" Make sure your SMTP configuration is working properly before using this command or you will have multiple errors.

jdt-generator's People

Contributors

azecko avatar

Stargazers

Nicolas Borboën avatar

Watchers

 avatar

Forkers

ponsfrilus

jdt-generator's Issues

Good README.md file

README.md needs to explain how to authenticate and use the program correctly.

Crontab ????

Imagine not having to even think about sending by e-mail your report because it's automated..

Evolution for other sources

According to the following timesheet format:

# July -- this is also a comment
2022-07-01 09:00 60 18:30 Some activity, another activity

2022-07-04 09:00 90 18:00 [Teletravail] Some activity, another activity
2022-07-05 08:00 60 17:30 [Teletravail] Some activity, another activity
2022-07-06 08:45 60 18:00 [EPFL] Some activity, another activity
2022-07-07 09:00 60 18:15 [Teletravail] Some activity, another activity
2022-07-08 09:00 60 18:15 [Teletravail] Some activity, another activity

2022-07-11 08:30 12:00 13:00 18:30 [EPFL] With full epoch at noon.
2022-07-12  08:30 60  18:15    [EPFL] This should work even with too much space
2022-07-13 09:00 60 18:15 Can't remember
2022-07-14 08:15 45 18:15 120 [Teletravail] This one has 120 minutes of overtime.
2022-07-15 09:00 0 18:12 [Teletravail] Reprise heures appoints

2022-07-18 09:00 0 18:12 vacances
2022-07-19 09:00 0 18:12 vacances
2022-07-20 09:00 0 18:12 vacances
2022-07-21 09:00 0 18:12 vacances
2022-07-22 09:00 0 18:12 vacances

2022-07-25 09:00 0 18:12 vacances
2022-07-26 09:00 0 18:12 vacances
2022-07-27 09:00 0 18:12 vacances
2022-07-28 09:00 0 18:12 vacances
2022-07-29 09:00 0 18:12 vacances

would I be able to use jdt-generator ?

I would like to have a the ability to generate the following report:

  • one line by day : ISODATE, Total Hours, Total Hours Decimal (i.e. 8,5 = 08:30), Overtime (positive or negative, based on defined total hours), the description.
  • a summary of each month, Total Hours, expected hours, Overtime (positive or negative)
  • a summary of the full epoch (e.g. jan-sep, or the full year).

Additionally, anything like icon that can use the tags [EPFL] or [Teletravail] to quickly see if the day was remote work or not would be useful.

The following code (including the regex to parse a line) can be used:

const dbfile = 'data.txt"

const parseLine = (line) => {
  // This regex match both 
  // * 2022-10-01 10:00 11:00 12:00 16:00 60 description...
  // and
  // * 2022-10-01 10:00 60 16:00 60 description...
  const regex = /^(\d{4}-\d{2}-\d{2})\s+(\d{2}:\d{2})\s+(?:(\d{2})|((\d{2}:\d{2})\s+(\d{2}:\d{2})))\s+(\d{2}:\d{2})\s+(\d+)?\s?(.*)/
  const found = line.trim().match(regex)
  console.debug("found", found)
  if (found) {

    let entry = {
      'date': found[1],
      'start_time': found[2],
      'breaks': parseBreak(found),
      'end_time': found[7],
      'extra': found[8] || '',
      'description': found[9] || '',
      'total': '',
      'balance': ''
    }
    return entry
  } else if (line .trim() && !line.startsWith('#')) {
    console.error("The following line is malformed:", line)
  }
}
const parseBreak = (data) => {
  if (data[3]) return data[3]
  if (!data[3]) {
    console.log(data[4], data[5], data[6])
  }
}

let data = []
let rawData = fs.readFileSync(dbfile, 'utf8').split('\n')
for (let line of rawData) {
  line = parseLine(line)
  if (line) {
    data.push(line)
  }
}

Bot Telegram

Hello ! Here is your weekly report :

  • tototo
  • tototo

Would you send it to formateurs ?

Docker

Docker for the win!!!11!!!

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.