Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: handle more than 2 approved factcheck articles#51

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

maanasb01
Copy link
Collaborator

This PR addresses issue#149 in the DAU repository.

Changes Made

  • Fixed Error on More Than 2 Approved Articles

    • Previously, if more than 2 fact-check articles were approved, an error was raised, leading to an error page.
    • Theraise statement has been removed from the default condition to prevent this.
  • Updated Behavior When More Than 2 Articles Are Approved

    • Now, there is no error page. As there are no matching templates for more than 2 articles, the "User Response" section automatically displays: "No matching template found yet".
    • This prevents users from submitting a response if a valid template is not generated.
  • Added an Alert Message

    • When more than 2 articles are approved, an alert message appears, notifying the user. The "User Response" section also displays the no-match-found message.
    • If 2 or fewer articles are approved, the relevant template is displayed, and the alert is removed.
  • Future Needs

    • This approach also ensures that if, in the future, we want to allow more approved articles, we can do so with minimal tweaks in the code.
    • For instance, if we want to allow 3 articles, we would only need to proceed in the standard way we do now—adding relevant template names like"deepfake_wo_ar_3fc_en" and their contents. In thetemplate_name creation function, we would simply add a case for"3". That’s all!

Screenshots

Case: More Than 2 Approved Articles (Alert + No Template)

image

Case: 2 or Fewer Approved Articles (Template Visible, No Alert)

image

cc:@aatmanvaidya

@dennyabrain
Copy link
Contributor

can you check if all the relevant tests for templates pass with this change?

The resulting scenarios look good in the UI. I have some minor concern about the implementation.
I have an issue with removing the exception. The Template module is responsible for the all things related to message templates. Thetemplate_name_label is supposed to return valid template names. So if the number of approved fact checks is more than 2, raising an exception is the expected behavior. If we return a string from that function, its not right.

There must be a way to capture that exception and do appropriate things in the UI.

@maanasb01
Copy link
CollaboratorAuthor

Hey@dennyabrain, I have run all the tests in the/test/dau/user_message/templates directory, and every test case was successful.

Regarding your concern about the exception, thetemplate_name_label function is getting called insideassign_template_name in theFactory.process function (ref:https://github.com/tattle-made/dau-dashboard/blob/main/lib/dau/user_message/templates/factory.ex), where the common stuct is passed through a pipeline of different functions to return the template query with all the relevant data and metadata.

The issue is how thisFactory.process function gets called throughout the project. Inside thedetail.html.heex file, we are calling theFactory.process through different functions directly.Reference to the relevant line in the code.

In the above reference, in lines 375 and 377, we are calling functions that callFactory.process() and return different things. One returns a Boolean value for whether the template is valid or not. Other returns the template string that gets previewed in the "User Response" section.

As we approve any article, the@query state changes, triggering these functions. As these functions are not handle event callback functions, they don't have access to the socket. We can still use try and rescue to catch the error raised, but we cannot put any flash or update any state, indicating that some error has occurred. (We can update the User Message preview though, because it is returned by one of these functions and the output is directly rendered).

Also, in thetemplate_name_label function, it has to return a string for the normal execution of theFactory.process, as later, this string gets evaluated for checking the names. Currently (in this PR after removing "raise"), by default, it returns "Too many fact check articles", so if there are more than 2 articles approved, it would generate a template likedeepfake_wo_ar_Too many fact check articles_en, which is never going to match any case.

So, I understand that approving more articles is an unusual event, but in this case, it is checking "Too many articles" as a case and handling it automatically and then indicating that "there is no match for this case" as well in a standard way like it doing for all other unmatched cases.

One other way that we can approach this is to not allow adding more than the required articles in the beginning itself. But then we would also need to provide a way to delete the added articles as well (which I was thinking of adding as a feature in a separate issue on its own in any case).

Let me know your thoughts!

@dennyabraindennyabrain merged commit0eff420 intomainApr 28, 2025
1 check passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@maanasb01@dennyabrain

[8]ページ先頭

©2009-2025 Movatter.jp