-
Notifications
You must be signed in to change notification settings - Fork 18
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
Reveal keywords on project's catalogue page #225
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4016b53
Add & migrate DB keywords->count field
peterjdann 385c71e
Drop redundant keywords from projects
peterjdann d78ebd0
New cron job to update DB keywords->count field
peterjdann 4119a65
New functions in Project model to support keywords display
peterjdann cc60a1d
Display keywords details on catalog page
peterjdann be75d37
Display filterable, sortable list of projects that use specific keywords
peterjdann 3551da3
Update keywords statistics at catalog time
peterjdann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); | ||
|
||
class Keywords_stats extends CI_Controller | ||
{ | ||
public function update_keywords_stats() | ||
{ | ||
// Some keywords are not in use at all. | ||
// Initialise count field to zero before tallying counts. | ||
|
||
$sql = ' | ||
UPDATE keywords | ||
SET count = 0'; | ||
$this->db->query($sql); | ||
|
||
$sql = ' | ||
redrun45 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
UPDATE keywords | ||
JOIN | ||
(SELECT pk.keyword_id as keyword_id, COUNT(pk.project_id) AS count | ||
FROM project_keywords pk | ||
GROUP BY 1 | ||
) as sub | ||
ON keywords.id = sub.keyword_id | ||
SET keywords.count = sub.count '; | ||
$this->db->query($sql); | ||
|
||
} | ||
} | ||
|
||
|
||
/* End of file Keyword_stats.php */ | ||
/* Location: ./application/controllers/cron/Keyword_stats.php */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
defined('BASEPATH') OR exit('No direct script access allowed'); | ||
|
||
class Migration_Add_keywords_count_field extends CI_Migration { | ||
|
||
public function up() | ||
{ | ||
$fields = array( | ||
'count' => array('type' => 'INT', | ||
'default' => '0', | ||
'after' => 'value') | ||
); | ||
$this->dbforge->add_column('keywords', $fields); | ||
} | ||
|
||
public function down() | ||
{ | ||
$this->dbforge->drop_column('keywords', 'count'); | ||
} | ||
} | ||
|
52 changes: 52 additions & 0 deletions
52
application/migrations/004_drop_redundant_keywords_from_projects.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
defined('BASEPATH') OR exit('No direct script access allowed'); | ||
|
||
class Migration_Drop_redundant_keywords_from_projects extends CI_Migration { | ||
|
||
public function up() | ||
{ | ||
$sql = ' | ||
DELETE pk2.* | ||
FROM project_keywords pk2 | ||
WHERE keyword_id IN | ||
( | ||
SELECT id | ||
FROM keywords k | ||
WHERE k.value in ( | ||
"librivox", | ||
"ibrivox", | ||
"llibrivox", | ||
"librixox", | ||
"librivox;", | ||
"libriox", | ||
"libirivox", | ||
"librivos", | ||
"audio", | ||
"audiobook", | ||
"audiobooks", | ||
"audio books", | ||
"audio book", | ||
"audioboek", | ||
"audiobuch", | ||
"audiobooklibrivox", | ||
"audibook", | ||
"audioook", | ||
"autiobook", | ||
"audiobook:", | ||
"audioboo", | ||
"audiolibro", | ||
"audio libro", | ||
"audiolibros", | ||
"audiolivre", | ||
"audiolivro" | ||
) | ||
)'; | ||
$this->db->query($sql); | ||
} | ||
|
||
public function down() | ||
{ | ||
; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to remember to add a line to https://github.com/LibriVox/librivox-ansible/blob/master/roles/common/files/daily-cron to actually run this. Is daily enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From admin side, I'd say so. We're used to some processes running overnight, so for anything that isn't immediate, that's a "no surprise" interval. 👍