Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send email of locations / generators alerts to users #45

Closed
1 task
pferrariuy opened this issue May 26, 2024 · 1 comment · Fixed by #46
Closed
1 task

Send email of locations / generators alerts to users #45

pferrariuy opened this issue May 26, 2024 · 1 comment · Fixed by #46
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@pferrariuy
Copy link
Collaborator

pferrariuy commented May 26, 2024

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:

  • Client is enabled to send alerts by email
  • Location / Generator is enabled to send alerts by email
  • Alert has not been send by email before
  • The alert must by seend to all users (with access to the client + location / generator) that are enabled to receive alerts by email

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

  • Every day at 6 am, a series of emails are send email to each user with the corresponding alert information (1 email by alert).
  • No alerts, then no email.

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:

  • cli_gen_usr_alert
  • cli_loc_usr_alert

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

  • Adjusts email template to UI of app
@pferrariuy
Copy link
Collaborator Author

pferrariuy commented May 26, 2024

Added new flags to:

  • Client:
    • FLAG_RECEIVE_ALERT_LOCATION_BY_EMAIL = 2
    • FLAG_RECEIVE_ALERT_GENERATOR_NBY_EMAIL = 3
  • Location: FLAG_ENABLED_FOR_EMAIL_ALERT = 3
  • Generator: FLAG_ENABLED_FOR_EMAIL_ALERT = 1
  • Client Location Alert: FLAG_SEND_BY_EMAIL = 1
  • Client Generator Alert: FLAG_SEND_BY_EMAIL = 1

Uses views (Renovus-Tech/solarec-db#15):

  • vw_cli_gen_alert_to_send_by_email
  • vw_cli_loc_alert_to_send_by_email

New email template:

  • email_alert.html

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>

pferrariuy added a commit that referenced this issue May 26, 2024
added support for location alerts, adjusted logback.xml sample file

Related to #45
pferrariuy added a commit that referenced this issue May 26, 2024
Related to #45
pferrariuy added a commit that referenced this issue May 27, 2024
pferrariuy added a commit that referenced this issue May 27, 2024
pferrariuy added a commit that referenced this issue May 27, 2024
Send email of locations / generators alerts to users #45 to MAIN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant