Skip to content

Commit

Permalink
Renamed part_reindex_frequency to incremental_reindex_frequency, full…
Browse files Browse the repository at this point in the history
…_indexing_status to indexing_status, full_indexing_status_changed to indexing_status_changed, part_indexing_status to last_index_completed, part_indexing_status_changed to last_full_index_completed, and default_part_reindex_frequency to default_incremental_reindex_frequency, for #34
  • Loading branch information
m-i-l committed Oct 8, 2022
1 parent fb7945b commit 4644d40
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 27 deletions.
14 changes: 7 additions & 7 deletions src/db/sql/init-tables.inc
Expand Up @@ -23,18 +23,18 @@ CREATE TABLE tblDomains (
moderator_action_changed TIMESTAMPTZ,
moderator TEXT, -- domain of moderator
full_reindex_frequency INTERVAL,
part_reindex_frequency INTERVAL,
incremental_reindex_frequency INTERVAL,
indexing_page_limit SMALLINT,
on_demand_reindexing BOOLEAN,
api_enabled BOOLEAN,
indexing_enabled BOOLEAN,
indexing_disabled_reason TEXT, -- only set when indexing_enabled = FALSE
indexing_disabled_changed TIMESTAMPTZ,
indexing_type TEXT, -- Just 'spider/default' now, but there was a 'bulkimport/wikipedia'
full_indexing_status TEXT, -- 'PENDING', 'RUNNING', 'COMPLETE'
full_indexing_status_changed TIMESTAMPTZ,
part_indexing_status TEXT, -- 'PENDING', 'RUNNING', 'COMPLETE'
part_indexing_status_changed TIMESTAMPTZ,
indexing_status TEXT, -- 'PENDING', 'RUNNING', 'COMPLETE'
indexing_status_changed TIMESTAMPTZ,
last_index_completed TIMESTAMPTZ,
last_full_index_completed TIMESTAMPTZ,
last_login TIMESTAMPTZ,
forgotten_password_key TEXT,
forgotten_password_key_expiry TIMESTAMPTZ
Expand All @@ -44,7 +44,7 @@ CREATE TABLE tblTiers (
tier SMALLINT PRIMARY KEY,
tier_name TEXT,
default_full_reindex_frequency INTERVAL,
default_part_reindex_frequency INTERVAL,
default_incremental_reindex_frequency INTERVAL,
default_indexing_page_limit SMALLINT,
default_on_demand_reindexing BOOLEAN,
default_api_enabled BOOLEAN,
Expand Down Expand Up @@ -130,7 +130,7 @@ CREATE TABLE tblSettings (
);

INSERT INTO tblTiers
(tier, tier_name, default_full_reindex_frequency, default_part_reindex_frequency, default_indexing_page_limit, default_on_demand_reindexing, default_api_enabled, cost_amount, cost_currency, listing_duration)
(tier, tier_name, default_full_reindex_frequency, default_incremental_reindex_frequency, default_indexing_page_limit, default_on_demand_reindexing, default_api_enabled, cost_amount, cost_currency, listing_duration)
VALUES
(1, 'Basic', '28 days', '7 days', 50, FALSE, FALSE, 0.00, '£', '1 year'),
(2, 'Free Trial', '28 days', '7 days', 100, FALSE, TRUE, 0.00, '£', '1 month'),
Expand Down
17 changes: 11 additions & 6 deletions src/web/content/dynamic/searchmysite/admin/add.py
Expand Up @@ -14,7 +14,7 @@

# SQL

sql_select_tiers = "SELECT tier, tier_name, default_full_reindex_frequency, default_part_reindex_frequency, default_indexing_page_limit, default_on_demand_reindexing, default_api_enabled, cost_amount, cost_currency, listing_duration "\
sql_select_tiers = "SELECT tier, tier_name, default_full_reindex_frequency, default_incremental_reindex_frequency, default_indexing_page_limit, default_on_demand_reindexing, default_api_enabled, cost_amount, cost_currency, listing_duration "\
"FROM tblTiers;"

# Selects the status of the highest listed tier (whether active or not)
Expand Down Expand Up @@ -61,13 +61,13 @@
"WHERE domain = (%s) AND tier = (%s); "\
"UPDATE tblDomains SET "\
"full_reindex_frequency = tblTiers.default_full_reindex_frequency, "\
"part_reindex_frequency = tblTiers.default_part_reindex_frequency, "\
"incremental_reindex_frequency = tblTiers.default_incremental_reindex_frequency, "\
"indexing_page_limit = tblTiers.default_indexing_page_limit, "\
"on_demand_reindexing = tblTiers.default_on_demand_reindexing, "\
"api_enabled = tblTiers.default_api_enabled, "\
"indexing_enabled = TRUE, "\
"full_indexing_status = 'PENDING', "\
"full_indexing_status_changed = NOW() "\
"indexing_status = 'PENDING', "\
"indexing_status_changed = NOW() "\
"FROM tblTiers WHERE tblTiers.tier = (%s) and tblDomains.domain = (%s);"

sql_select_validation_key = "SELECT validation_key FROM tblValidations WHERE domain = (%s);"
Expand Down Expand Up @@ -325,7 +325,7 @@ def success():

# Fields in tblTiers:
# tier_no, tier_name,
# default_full_reindex_frequency, default_part_reindex_frequency, default_indexing_page_limit, default_on_demand_reindexing, default_api_enabled,
# default_full_reindex_frequency, default_incremental_reindex_frequency, default_indexing_page_limit, default_on_demand_reindexing, default_api_enabled,
# cost_amount, cost_currency, listing_duration
def get_tier_data():
tiers = []
Expand All @@ -341,10 +341,15 @@ def get_tier_data():
# tier_name
tier['tier_name'] = result['tier_name']
# full_reindex_frequency
full_reindex_frequency = 'Every ' + str(result['default_full_reindex_frequency'])
full_reindex_frequency = str(result['default_full_reindex_frequency'])
if full_reindex_frequency.endswith(', 0:00:00'): # Only tidies whole days for now, half days would end ', 12:00:00'
full_reindex_frequency = full_reindex_frequency.replace(', 0:00:00', '')
tier['full_reindex_frequency'] = full_reindex_frequency
# incremental_reindex_frequency
incremental_reindex_frequency = str(result['default_incremental_reindex_frequency'])
if incremental_reindex_frequency.endswith(', 0:00:00'):
incremental_reindex_frequency = incremental_reindex_frequency.replace(', 0:00:00', '')
tier['incremental_reindex_frequency'] = incremental_reindex_frequency
# indexing_page_limit
indexing_page_limit = str(result['default_indexing_page_limit']) + ' pages'
tier['indexing_page_limit'] = indexing_page_limit
Expand Down
6 changes: 3 additions & 3 deletions src/web/content/dynamic/searchmysite/admin/admin.py
Expand Up @@ -26,13 +26,13 @@
"moderator_approved = TRUE, "\
"moderator = (%s), "\
"full_reindex_frequency = tblTiers.default_full_reindex_frequency, "\
"part_reindex_frequency = tblTiers.default_part_reindex_frequency, "\
"incremental_reindex_frequency = tblTiers.default_incremental_reindex_frequency, "\
"indexing_page_limit = tblTiers.default_indexing_page_limit, "\
"on_demand_reindexing = tblTiers.default_on_demand_reindexing, "\
"api_enabled = tblTiers.default_api_enabled, "\
"indexing_enabled = TRUE, "\
"full_indexing_status = 'PENDING', "\
"full_indexing_status_changed = NOW() "\
"indexing_status = 'PENDING', "\
"indexing_status_changed = NOW() "\
"FROM tblTiers WHERE tblTiers.tier = 1 and tblDomains.domain = (%s);"

sql_update_basic_reject = "UPDATE tblListingStatus "\
Expand Down
22 changes: 11 additions & 11 deletions src/web/content/dynamic/searchmysite/admin/manage.py
Expand Up @@ -24,7 +24,7 @@
sql_update_value = "UPDATE tblDomains SET %s = (%s) WHERE domain = (%s);"
sql_insert_filter = "INSERT INTO tblIndexingFilters VALUES ((%s), 'exclude', (%s), (%s));"
sql_delete_filter = "DELETE FROM tblIndexingFilters WHERE domain = (%s) AND action = 'exclude' AND type = (%s) AND VALUE = (%s);"
sql_update_indexing_status = "UPDATE tblDomains SET full_indexing_status = 'PENDING', full_indexing_status_changed = now() WHERE domain = (%s); "\
sql_update_indexing_status = "UPDATE tblDomains SET indexing_status = 'PENDING', indexing_status_changed = now() WHERE domain = (%s); "\
"INSERT INTO tblIndexingLog VALUES ((%s), 'PENDING', now());"
sql_select_tier = "SELECT l.status, l.tier, t.tier_name, l.listing_end FROM tblListingStatus l INNER JOIN tblTiers t ON t.tier = l.tier WHERE l.domain = (%s) AND l.status = 'ACTIVE' ORDER BY tier DESC LIMIT 1;"
sql_upgrade_tier2_to_tier3 = "UPDATE tblListingStatus SET status = 'EXPIRED', status_changed = NOW() WHERE domain = (%s) AND tier = 2; "\
Expand Down Expand Up @@ -53,15 +53,15 @@

# Manage Site / Indexing
# Notes:
# There isn't a database field for next_reindex - this will be populated in get_manage_data based on full_indexing_status, full_indexing_status_changed and full_reindex_frequency
# There isn't a database field for next_reindex - this will be populated in get_manage_data based on indexing_status, indexing_status_changed and full_reindex_frequency
# There aren't database fields for web_feed and sitemap - this will be populated in get_manage_data based on web_feed_auto_discovered and web_feed_user_entered
manage_indexing_form = [
{'label':'indexing_enabled', 'label-text':'Indexing enabled', 'type':'text', 'class':'form-control-plaintext', 'editable':False, 'help':'True if indexing is enabled, and False if indexing is disabled (e.g. because of repeated failed indexing attempts).'},
{'label':'include_in_public_search', 'label-text':'Include in public search', 'type':'text', 'class':'form-control-plaintext', 'editable':False, 'help':'True if content from this site is to be included in the public search (along with Browse, Newest and Random).'},
{'label':'full_indexing_status', 'label-text':'Indexing current status', 'type':'text', 'class':'form-control-plaintext', 'editable':False, 'help':'The latest status of indexing (either RUNNING, COMPLETE, PENDING).'},
{'label':'full_indexing_status_changed', 'label-text':'Indexing status last updated', 'type':'text', 'class':'form-control-plaintext', 'editable':False, 'help':'The time the indexing status was last changed.'},
{'label':'full_reindex_frequency', 'label-text':'Indexing frequency', 'type':'text', 'class':'form-control-plaintext', 'editable':False, 'help':'The time period between site reindexing.'},
{'label':'next_reindex', 'label-text':'Next reindex', 'type':'text', 'class':'form-control-plaintext', 'editable':False, 'help':'Earliest start time for the next reindex.'},
{'label':'indexing_status', 'label-text':'Indexing current status', 'type':'text', 'class':'form-control-plaintext', 'editable':False, 'help':'The latest status of indexing (either RUNNING, COMPLETE, PENDING).'},
{'label':'indexing_status_changed', 'label-text':'Indexing status last updated', 'type':'text', 'class':'form-control-plaintext', 'editable':False, 'help':'The time the indexing status was last changed.'},
{'label':'full_reindex_frequency', 'label-text':'Full reindexing frequency', 'type':'text', 'class':'form-control-plaintext', 'editable':False, 'help':'The time period between full reindexes of the site.'},
{'label':'next_reindex', 'label-text':'Next full reindex', 'type':'text', 'class':'form-control-plaintext', 'editable':False, 'help':'Earliest start time for the next full reindex.'},
{'label':'web_feed', 'label-text':'Web feed', 'type':'text', 'class':'form-control', 'editable':True, 'help':'This is the web feed (RSS or Atom), used for indexing and for identifying pages which are part of a feed. The system tries to identify a feed but it can be entered or overridden here.'},
{'label':'indexing_page_limit', 'label-text':'Indexing page limit', 'type':'text', 'class':'form-control-plaintext', 'editable':False, 'help':'The maximum number of pages on your domain which will be indexed.'},
{'label':'indexing_type', 'label-text':'Indexing type', 'type':'text', 'class':'form-control-plaintext', 'editable':False, 'help':'What mechanism is used to index the site. In almost all cases it will be the default spider.'},
Expand Down Expand Up @@ -218,15 +218,15 @@ def get_manage_data(domain, manage_form):
manage_data['indexing_disabled_reason'] = result['indexing_disabled_reason']
elif label == 'domain_first_submitted' and result['domain_first_submitted']:
manage_data['domain_first_submitted'] = result['domain_first_submitted'].strftime('%d %b %Y, %H:%M%z')
elif label == 'full_indexing_status_changed' and result['full_indexing_status_changed']:
manage_data['full_indexing_status_changed'] = result['full_indexing_status_changed'].strftime('%d %b %Y, %H:%M%z')
elif label == 'indexing_status_changed' and result['indexing_status_changed']:
manage_data['indexing_status_changed'] = result['indexing_status_changed'].strftime('%d %b %Y, %H:%M%z')
else:
manage_data[label] = result[label]
elif label == 'next_reindex':
if result['full_indexing_status'] == 'PENDING':
if result['indexing_status'] == 'PENDING':
next_reindex = "Any time now"
elif result['full_indexing_status_changed'] and result['full_reindex_frequency']:
next_reindex_datetime = result['full_indexing_status_changed'] + result['full_reindex_frequency']
elif result['indexing_status_changed'] and result['full_reindex_frequency']:
next_reindex_datetime = result['indexing_status_changed'] + result['full_reindex_frequency']
next_reindex = next_reindex_datetime.strftime('%d %b %Y, %H:%M%z')
else: # This shouldn't happen, but just in case
next_reindex = "Not quite sure"
Expand Down

0 comments on commit 4644d40

Please sign in to comment.