Coder Social home page Coder Social logo

hermix-eu / sicap-watcher Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ciocan/sicap-watcher

0.0 0.0 0.0 84 KB

Sistem de alertare pe email atunci cand o companie are contracte noi adaugate in SICAP

License: MIT License

Shell 0.74% JavaScript 99.26%

sicap-watcher's Introduction

sicap-watcher sistem de alertare pe email atunci cand o companie are contracte noi adaugate in SICAP

Functionare:

Atunci cand este exacutat, scriptul cauta in achizitii-directe si licitatii-publice din Elasticsearch toate contractele din ultimele 48 de ore filtrate dupa lista de coduri fiscale.

Lista companiilor urmarite se afla in indexul alerte si are documente cu urmatoarea structura:

{
  "_index" : "alerte",
  "_type" : "_doc",
  "_id" : "[email protected]",
  "_score" : 1.0,
  "_source" : {
    "cui" : [
      "12345678",
      "7612464",
      "416103"
    ]
  }

cui reprezinta lista cu codurile fiscale urmarite, iar adresa de email este reprezentata ca si cheie unica de _id -ul documentului.

Toate contractele noi gasite sunt compilate in template-ul html si trimise catre email-ul documentului.

Atunci cand un contract nou este gasit, va fi adaugat in alerte-log ca document cu urmatoarea structura:

{
  "_index" : "alerte-log",
  "_type" : "_doc",
  "_id" : "[email protected]",
  "_score" : 1.0,
  "_source" : {
    "email" : "[email protected]",
    "id" : 1233434,
    "type" : "achizitii",
    "date" : "2020-08-17T14:18:59.059Z"
  }
},

Script-ul verifica intai daca un contract nou exista in alerte-log, pentru a nu fi trimis de doua ori.

Instalare:

Creeaza index alerte, alerte-log si alerte-errors in Elasticsearch

Redenumeste fisierul .env.example in .env si completeaza ES_NODE cu adresa serverului de Elasticsearch, adresa de email si api key-ul de la Sendgrid pentru a putea trimite mesaje.

git clone [email protected]:ciocan/sicap-watcher.git
npm install
npm link

.env

export HOURS=48
export FROM_EMAIL=''
export ES_NODE=''
export SENDGRID_API_KEY=''

Mod de utilizare: Inainte de a rula script-ul trebuie sa ai variabilele de mediu in memorie.

source .env
sicap-watcher

Script-ul se poate pune in crontab sa fie executat odata pe zi, dupa ce contractele din ziua respectiva sunt indexate in Elasticsearch.

sicap-watcher's People

Contributors

sicap-user avatar ciocan avatar

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.