Personal Information
Name : Anirudh Jain
Nickname : Cyna
IRC nick : Cyna
Musicbrainz userid : anirudhjain75
Email : anirudh.jain@outlook.com
GitHub :https://github.com/anirudhjain75
Twitter :https://twitter.com/anirudhjain75
Proposal
Objective
My objective is to create a notification system for editors in musicbrainz so that they are notified when various events take place on their subscribed entities (i.e. Artists, Albums, Collections, etc) and votes . This is an enhancement over the current notification system which uses emails, to have an additional in-browser notifications management and add i18n to the mix allowing translations of notifications as well. This would prevent email spamming to editors. After the project, the editor would be able to opt on email notifications / in browser notifications or both or none.
Solution
Finalizing the database schema and writing and endpoint to populate the database using SQL queries and data from the perl function called to invoke data changes to the database. the ones created for email notifications would be reused and follow the same convention for further modifications, The formatting of text and translation will be handled before pushing the notification to the notification database.
After completing the API in backend, the task is to move forward with the UI to consume the API /get_notifications created in the previous approach. The parameter would be the editor.id ( used as key identified of ownership of the notifications ).
Creating a basic user interface with a bell icon and overlay of notifications when clicking on it. In addition there would be a notifications page that would contain a list of all notifications received by MusicBrainz for the user. A simple demo can be viewed using the below figma prototype
https://www.figma.com/file/HVBTB4PAk7MBkfEqhkk9Kc/MusicbrainzNotifications?node-id=0%3A1
Clicking on the notification icon ( bell icon ) reveals a small overlay to display short list notifications. And clicking on Show All in minor preview would display the notifications page coupled along with other user attributes. This notifications page can be used to track all the previous notifications / alerts generated that are not visible on the notifications preview.
In addition to adding notification systems to browser level. Translated notifications will also be possible using i18n currently followed in musicbrainz website improving upon email notifications which do not support translated notifications.
Notification Schema that will be used and referred for the project
- id [SERIAL] PK
- receiver_id ( editor.id ) [INTEGER]
- content [TEXT]
- datetime_added [TIMESTAMP WITH TIME ZONE]
- datetime_read [BOOLEAN]
- sender_id [INTEGER]
Types of Notifications currently supported by Musicbrainz Project
- Changes in Subscribed Entities
- Changes by Subscribed editor
- Deletion of Subscribed Entity
Details on Each Notifications and their shorthands to be used
New Releases - Not used at the moment
Change format to limit 1 release per notification for clearer message. Email sends bulk of releases as single notification
Shorthand : New Release - Blood of Cromos by Iron Maiden
Long : Blood of Cromos by Iron Maiden released on 10th feb 2077 on Spotify
ClickableLink : Points to release with name - Blood of Cromos by Iron Maiden
Changes to Subscribed Entities ( artist, collection, labels, series ) - admin/ProcessSubscriptions
Shorthand : Edits made to Iron Maiden Artist
Long : Edits made to Iron Maiden Artist by $editorName
ClickableLink : $ ServerURL /artist/ $IronMaidenGid /edits
Shorthand : Edits made to Blood of Cromos collection
Long : Edits made to Blood of Cromos collection by $editorName
ClickableLink : $ ServerURL /artist/ $IronMaidenGid /edits
Deletion of Subscribed Entities - admin/ProcessSubscriptions
Shorthand : Blood of Cromos has been deleted or merged( Collection )
Long : Some of your subscribed artists, labels or collections have been merged, deleted or made private
Clickable : $ServerURL /edit/ $EditIdentifier
Changes by Subscribed Editor - admin/ProcessSubscriptions
Shorthand : Changes made by yvanzo
Long : Changes made by yvanzo
ClickableLink : $ServerURL /user/ yvanzo /edits
AutoEditorElections - Hourly.sh
ClickableLink - /election/electionId
Accepted Edit
Shorthand : $ CandidateName has been accepted as an auto editor
Long : Voting in this election is now closed: $ CandidateName has been
accepted as an auto-editor. Congratulations! For more details, click here
Cancelled Edit
Shorthand : Election has been cancelled by Proposer ( $ProposerName )
Long : This election has been cancelled by the proposer ( $ProposerName ). For more details, click here
Nominated Edit
Shorthand : A new candidate has been put forward for auto editor status
Long : A new candidate has been put forward for autoeditor status:
Candidate: $CandidateName
Proposer: $ProposerName
Rejected Edit
Shorthand : The proposal to make $CandidateName an auto editor was declined
Long : Voting in this election is now closed: the proposal to make $CandidateName an auto-editor was declined. For more details, click here,
Timeout Edit
Shorthand : Elections have been cancelled due to timeout
Long : This election has been cancelled, because two seconders could not be found within the allowed time. For more details, click here
Voting open for Edit
Shorthand : Voting ot elect auto editor is now open
Long : Voting to elect $CandidateName as auto editor has been proposed by $ProposerName. For more details, click here.
The Project can be split into 3 phases.
- Writing SQL queries and modifying schema
- Creating Web API in Perl to be consumed by the web interface and the backend interacts with notifications table.
- Creation of Web Interface
Writing SQL queries and Modifying schema.
SQL queries need to be written for two operations. Adding notification to Notifications bank of a user ( requested and performed by the server ). Fetching notifications of a user ( requested from client and performed by the server ). Reference to schema can be found in the above topic.
Creating Web API in Perl to be used by the web interface.
Web API endpoints have to be created to invoke and get the json response of a list of notifications of a user. The endpoint /get_notifications which would earlier be handled by backend would make things dynamic and work with the database.
Creation of Web Interface
This contains adding notification icon, notification preview and notifications page. The test would be done using API created to fetch notifications.
How are notifications being populated for a user ?
Notifications are being handled by cron jobs running all the time on musicbrainz server. Daily, Hourly and Weekly.
Hourly cron jobs run to populate / create mail for users compiling the list of election results and votes the editor is interested in.
Daily / Weekly cron jobs are used for notifying users on entities they are subscribed to
Later simple addition to allow p2p messaging can be made by using instantaneous / queued messaging for heavy load. New functions to modify data to add messages to the database will be created to push notification at the moment they are made
How will they be added to Musicbrainz current system ?
All notifications generated on mail are based on functions and I will interject code to add the same notification by making some change to the format to the database. This would serve as the source for /getNotification API.
How will translations be handled
Three plan of implementing translations are possible.
-
Let UI handle the notifications translation using l, lp tag as used by other components. Drawbacks are the transifex will be called many times for a single editor for the same language.
-
Let backend handle the notification translation by translation on trigger and store in database in translated format. Drawback is that if editor changes the language, there would be no simple way to translate the context as they would be translated and stored in database, this can be worked on by storing multiple languages of notification when requested by adding language parameter to schema. which might effect the storage size of the database.
-
Let UI handle the translation but use json file with i18n to handle the translation on UI end. Any additional text would have to be translated and updated in the json file. For more info on the module that can be used. https://www.npmjs.com/package/i18n-react
I will be going with first approach as per the mentor’s suggestion. The solution is so simply use the existing way on how things are translated in musicbrainz website. ( using l, lp tags in javascript ). The use of l, lp automatically translated the entire content based on existing templates in Transifix. An example could be seen at musicbrainz-server/root/artist/ArtistIndex.js on how L tag is used. Translations can be found in .po files in musicbrainz-server/po.
Currently I have some confusions on how I’ll add more strings to be translated to the existing translation system. Although the l tag can be used both with and without parameter therefore adding links and other replacements are possible.
Usage :
l('You may proceed to <a href=\"{url}\">your user profile</a>,
or maybe you want to {edit_link}', url => c.uri_for('/user/profile
'), edit_link => doc_link("How_Editing_Works", l("start editing!"))
Somewhere around the lines of this would be written for all the statements and then added so in theory the translations should work with the currently selected language as its done already by the website.
Implementation timeline
7th June - 13th June : Finalize the proposed schema and complete the backend API /get_notifications
14th June - 20th June : Handing the test cases for the API ensuring its working
21st June - 27th June : Inject code in functions of hourly, daily and weekly cron jobs to populate notifications database based on schema and refactor based on above mentioned strings.
28th June - 4th July : Adding test cases if any, Finalize the working on the backend and the API to progress with the UI
5th July - 11th July : Complete a basic UI as proposed and add setting to toggle in browser notification
12th July - 16th July - Phase 1 Evaluations : Basic UI with backend and API completed
17th July - 23rd July : Work on adding translations to the mix and investigate p2p messaging using notifications approach.
24th July - 30th July : Create functions for sending instantaneous messages instead of cron jobs for p2p messaging and other required alerts.
31st July - 6th August : Write test cases if any, Ensure the work on p2p messaging / instantaneous notifications are complete.
7th August - 15th August : Buffer period for any pending backlogs or improvements suggested on real time
16th August - 23rd August : Push the remaining code for review and finalize the completion of project
Other Information
1. Tell us about the computer(s) you have available for working on your SoC project!
I have macbook pro 2015 with 16 gb ram. And a custom built pc with ryzen 5600x, 16gb and rtx 3070.
2. When did you first start programming?
During High School - 2017
3. What type of music do you listen to? (Please list a series of MBIDs as examples.)
Nothing Else Matters - Metallica
Stairway to Heaven - Led Zeppellin
4. What aspects of the project you're applying for (e.g., MusicBrainz, AcousticBrainz, etc.) interest you the most?
Notification system being one of the most basic feature yet highly required by most sites for an interactive experience with users. The aspect of creating it for a majorly released website is in itself a good opportunity as well as the research and reason behind what is the best way to implement it is a good architectural challenge for me, which obviously I am interested the most to solve.
5. Have you ever used MusicBrainz to tag your files?
I haven't used it yet and hope to use it in future if I actually have music files stored on my PC. I usually use online music services such as Spotify, Apple Music and Youtube Music.
6. Have you contributed to other Open Source projects? If so, which projects and can we see some of your code?
Yes I have contributed to Layer5's Meshery project as well as Musicbrainz project of Metabrainz Foundation.
7. What sorts of programming projects have you done on your own time?
I have done a couple of programming projects, Websites with Accessibility options ( Real time gestures recognition, Voice based Navigation, Various color effects for partial blindness aid ), Creating Game Servers using Kubernetes Manifest ( I've made one for Ark Survival Evolved ), Writing API server using API Gateway and AWS lambda for Voice Assistant ( in my case, Primarily to build skill for Amazon Alexa ). And a lot more.
8. How much time do you have available, and how would you plan to use it?
I have about 4-5h a day allocated for Summer of Code. I plan on learning anything I need to complete the project ( in my case, Perl with MOOSE ) and implementing it. I plan on wrapping the project early to work on enhancements to the notification system.