src/service.js
/**
   * Adds a health facility to the queue.
   * @param  {Object} facility Facility to be saved.
   */
Adds a health facility to the queue.
@param  {Object} facility Facility to be saved.
Adds a health facility to the queue . @param { Object } facility Facility to be saved .
addFacility(facility) {
    let isAccepted = IGNORED_FACILITY_TYPES.every(ignored => (facility.type.indexOf(ignored) === -1));
    if (isAccepted) {
      this.writeRequests.set(facility.id, {
        RangeKeyValue: {
          S: facility.id
        },
        GeoPoint: {
          latitude: facility.latitude,
          longitude: facility.longitude
        },
        PutItemInput: {
          Item: {
            facilityId: {
              N: facility.id
            },
            ibge: {
              N: facility.ibge
            },
            name: {
              S: facility.name
            },
            businessName: {
              S: facility.businessName
            },
            type: {
              S: facility.type
            },
            openingHours: {
              S: facility.openingHours
            },
            phone: {
              S: facility.phone
            },
            latitude: {
              N: facility.latitude
            },
            longitude: {
              N: facility.longitude
            },
            street: {
              S: facility.address.street
            },
            addressNumber: {
              S: facility.address.number
            },
            neighborhood: {
              S: facility.address.neighborhood
            },
            postalCode: {
              S: facility.address.postalCode
            },
            state: {
              S: facility.address.state
            },
            city: {
              S: facility.address.city
            },
            services: {
              SS: facility.services
            }
          }
        }
      });
    } else {
      this.ignored++;
    }
    if (!this.countSleeping) {
      this.countSleeping = true;
      setTimeout(() => {
        if (!this.commitStarted) {
          this.countSleeping = false;
          log.info(`${this.writeRequests.size} facilities added to the queue and ${this.ignored} ignored so far...`);
        }
      }, 5000);
    }
  }
addFacility ( facility ) { let isAccepted = IGNORED_FACILITY_TYPES . every ( ignored => ( facility . type . indexOf ( ignored ) === - 1 ) ) ; if ( isAccepted ) { this . writeRequests . set ( facility . id , { RangeKeyValue : { S : facility . id } , GeoPoint : { latitude : facility . latitude , longitude : facility . longitude } , PutItemInput : { Item : { facilityId : { N : facility . id } , ibge : { N : facility . ibge } , name : { S : facility . name } , businessName : { S : facility . businessName } , type : { S : facility . type } , openingHours : { S : facility . openingHours } , phone : { S : facility . phone } , latitude : { N : facility . latitude } , longitude : { N : facility . longitude } , street : { S : facility . address . street } , addressNumber : { S : facility . address . number } , neighborhood : { S : facility . address . neighborhood } , postalCode : { S : facility . address . postalCode } , state : { S : facility . address . state } , city : { S : facility . address . city } , services : { SS : facility . services } } } } ) ; } else { this . ignored ++ ; } if ( ! this . countSleeping ) { this . countSleeping = true ; setTimeout ( ( ) => { if ( ! this . commitStarted ) { this . countSleeping = false ; log . info ( ` ${ this . writeRequests . size } ${ this . ignored } ` ) ; } } , 5000 ) ; } }
Adds a health facility to the queue.
Adds a health facility to the queue .
// checks if the facility type does not match any ignored type