Renovus-Tech / solarec-java

GNU Affero General Public License v3.0
0 stars 1 forks source link

Send email of locations / generators alerts to users #45

Closed pferrariuy closed 5 months ago

pferrariuy commented 5 months ago

Feature Request

Description

Generate a scheduler (execution at 6 am) that will retrieve all not send alert and will send them to the users, with their corresponding information. All alerts notifications must be send if all of the following conditions are meet:

Use Case

Location / Generator data is imported in the system. The alert service calcualtes and determinates an issue with the data. An alert is generated in the database (the same alert that the user will see when accessing to the dashboard). The system detects and send the alert by email.

Expected Behavior

Additional Context

The content of the email must be in the language configured by the user.

Implementation Suggestions

Record the result of alerts notifications to users in the corresponding table:

Impact on Existing Features

No impact in other features.

Additional Information

Users might have access to different clients (cli_user) and locations (loc_user), so notifications must be send to users with access to those client / location. For the case of a generator alert, use the loc_user verification.

Related Issues

Pendings

pferrariuy commented 5 months ago

Added new flags to:

Uses views (https://github.com/Renovus-Tech/solarec-db/issues/15):

New email template:

New label added:

email.generator.alert.subject = SolaREC Notification alert
email.location.alert.subject = SolaREC Notification alert

New logback configuration:

    <appender name="email_daily_appender" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${logFilePath}/email/email.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${logFilePath}/email/email.%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>7</maxHistory> <!-- Keep logs for 7 days -->
        </rollingPolicy>
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>

    <logger name="email"        level="all" additivity="true"><appender-ref ref="email_daily_appender"/></logger>