Skip to content

Module reference

Kunal Nagpal edited this page Apr 24, 2016 · 7 revisions

Directing focus to the database directory, we observe:

Sno Module Remarks
1 features Helper modules for team data.
2 helper Database helper modules.
3 passport Social authentication code.
4 record Holds the team object structure.
5 team Team data and associated tasks.
6 users User authentication and associated methods.

database/mongoFeatures.js

Sno Method Remarks
1 getStats Fetches overall game statistics (overall runs scored, et cetera).
2 notify Fetches feature request details.
3 simulate Runs simulation tasks (currently dormant).
4 forgotCount Fetches / updates the count of forgot password / user tasks.
5 warnEmptyTeams Sends an email to the owners of empty squads / teams.
6 match Given a match day and a team name, fetches either the opponent team or the match details.
7 fetchPlayers Fetches data to be passed to the player selection view.
8 getPlayer Fetches details for one particular player. Subordinate to fetchPlayers.
9 adminStats Fetches database details.

database/mongoHelper.js

Sno Method Remarks
1 scale Scales down bytes to KB / MB, as specified.
2 parse Process a string as Int / Float, as specified.
3 forgotCallback Returns a callback for forgot user / password operations.
4 shortlistRef A reference object for post-round completion shortlisting.

database/mongoRecord.js

Sno Method Remarks
1 schema Generates and returns a sample user instance.
2 users Returns an array of dummy users.
3 players Generates a set of dummy players and coaches.
4 info Returns a blank template for the info collection.
5 stats Returns a blank template for the stats collection.

database/mongoTeam.js

Sno Method Remarks
1 getTeam Fetches the team of 16 players.
2 getSquad Fetches the current playing eleven.
3 dashboard Fetches dashboard data.
4 map Given a team name, finds the team number.
5 shortList User authentication and associated methods.
6 adminInfo Fetches administrative statistics.
7 fetchMatches Fetches match day data for the current round, for all seven days.
8 opponent Given a team number and a match day, finds the opponent data for that pair.
9 squad Fetches individual player stats for a given team.

database/mongoUsers.js

Sno Method Remarks
1 getCount Calculates number of objects in the specified collection /current match collection.
2 insert Creates a new user or submits a feature request.
3 getLeader Fetches leaderboard data, and marks the present team, if existing.
4 forgotPassword Generates a time-bound password reset link and emails it to the user.
5 forgotUser Fetches team name details and emails the wrapped data to the user.
6 getReset Validates the password reset token for a given request.
7 resetPassword Resets the user password and sends confirmation email.
8 updateUserTeam Creates a team of players from the given selection.
9 updateMatchSquad Updates the playing eleven, only valid when the 16 player team has been chosen.
10 fetchUser Multi-purpose method used to login users or check if a user exists.