Skip to content

Commit

Permalink
Added Algolia Instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaiahJTurner committed Jun 12, 2014
1 parent 0a0fe53 commit b569b0f
Show file tree
Hide file tree
Showing 4 changed files with 127,165 additions and 4 deletions.
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Homework Hunt
![Homework Hunt](http://homeworkhunt.com/img/logo-dark.png)
=========

Homework Hunt is a state of the art site that provides two primary services.
Homework Hunt is a state of the art site that provides two primary services.

- Sharing homework.
- Finding answers to assignments.
Expand Down Expand Up @@ -30,7 +30,7 @@ Homework Hunt relies on a number of projects to work properly. Several are in bo
* [Twitter Bootstrap] - A sleek, intuitive, and powerful mobile first front-end framework.
* [Piwik] - Piwik is a open source web analytics application that runs on a PHP/MySQL server.
* [Font Awesome] - Font Awesome gives you scalable vector icons that can be customized.
* [jQuery] - jQuery is a fast, small, and feature-rich JavaScript library.
* [jQuery] - jQuery is a fast, small, and feature-rich JavaScript library.
* [Apache] - A secure, efficient and extensible server that provides HTTP services.
* [NGINX] - NGINX is the most popular open source web server for high-traffic websites

Expand All @@ -48,7 +48,15 @@ cd analytics
composer install
```

To finish the installation, open config.php and enter your own API keys and database connection settings.
To finish the installation, open config.php and enter your own API keys and database connection settings. If you would like to set up MySQL integration with Algolia, please follow these steps.

1. Move jdbc-connector.sh and config.sample.json to a new directory that is not accessible by the web.
2. Rename config.sample.json to config.json.
3. Open config.json and enter the requested data.
4. `cd` to the directory containing the jdbc-connector.sh script.
5. Execute `chmod +x jdbc-connector.s` in the terminal.
6. Ececute `./jdbc-connector.sh config.json` in the terminal.


License
----
Expand Down
12 changes: 12 additions & 0 deletions config.sample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"selectQuery" : "SELECT i.id, i.title, i.description, i.file, i.content, COALESCE(SUM(CASE WHEN a.isUpvote THEN 1 ELSE -1 END),0) AS rating FROM submissions AS i LEFT JOIN votes AS a ON i.id = a.post GROUP BY i.id",
"updateQuery" : "SELECT i.id, i.title, i.description, i.file, i.content, COALESCE(SUM(CASE WHEN a.isUpvote THEN 1 ELSE -1 END),0) AS rating FROM submissions AS i LEFT JOIN votes AS a ON i.id = a.post WHERE i.updated > _$ GROUP BY i.id",
"primaryField" : "id",
"updatedAtField": "updated",
"source" : "jdbc:mysql://HostnameOfYourDatabase/YourDatabaseName",
"username" : "Your MYSQL Username",
"password" : "Your MYSQL Password",
"applicationId" : "Your Algolia Application ID",
"apiKey" : "Your Algolia API Key",
"index" : "Your Algolia Index Name",
}
101 changes: 101 additions & 0 deletions homeworkhunt.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;


# Dump of table purchases
# ------------------------------------------------------------

DROP TABLE IF EXISTS `purchases`;

CREATE TABLE `purchases` (
`item` int(11) unsigned NOT NULL AUTO_INCREMENT,
`user` int(11) DEFAULT NULL,
`cost` tinyint(1) DEFAULT NULL,
PRIMARY KEY (`item`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;



# Dump of table sessions
# ------------------------------------------------------------

DROP TABLE IF EXISTS `sessions`;

CREATE TABLE `sessions` (
`id` int(11) NOT NULL,
`sid` varchar(255) NOT NULL,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
UNIQUE KEY `key` (`sid`),
KEY `index` (`id`),
CONSTRAINT `sessions_ibfk_1` FOREIGN KEY (`id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `sessions_ibfk_2` FOREIGN KEY (`id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `sessions_ibfk_4` FOREIGN KEY (`id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;



# Dump of table submissions
# ------------------------------------------------------------

DROP TABLE IF EXISTS `submissions`;

CREATE TABLE `submissions` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`description` text NOT NULL,
`hash` char(40) NOT NULL DEFAULT '',
`file` varchar(255) DEFAULT NULL,
`size` int(20) DEFAULT NULL,
`user` int(11) DEFAULT NULL,
`updated` timestamp NOT NULL ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;



# Dump of table users
# ------------------------------------------------------------

DROP TABLE IF EXISTS `users`;

CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`password` char(40) NOT NULL,
`creation` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`confirmed` tinyint(1) NOT NULL DEFAULT '0',
`spent` int(11) NOT NULL,
`trusted` tinyint(1) NOT NULL DEFAULT '0',
UNIQUE KEY `username` (`username`),
KEY `index` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;



# Dump of table votes
# ------------------------------------------------------------

DROP TABLE IF EXISTS `votes`;

CREATE TABLE `votes` (
`post` int(11) NOT NULL,
`user` int(11) NOT NULL,
`isUpvote` tinyint(1) NOT NULL DEFAULT '0',
UNIQUE KEY `unique_index` (`post`,`user`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;




/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
Loading

0 comments on commit b569b0f

Please sign in to comment.