You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@community.apache.org by hu...@apache.org on 2016/08/09 15:12:57 UTC
svn commit: r1755615 - in /comdev/helpwanted.apache.org/site: js/hw.js
listitems.lua tasks.lua widget.js wtest.html
Author: humbedooh
Date: Tue Aug 9 15:12:57 2016
New Revision: 1755615
URL: http://svn.apache.org/viewvc?rev=1755615&view=rev
Log:
sync with disk
Added:
comdev/helpwanted.apache.org/site/tasks.lua
Modified:
comdev/helpwanted.apache.org/site/js/hw.js
comdev/helpwanted.apache.org/site/listitems.lua
comdev/helpwanted.apache.org/site/widget.js
comdev/helpwanted.apache.org/site/wtest.html
Modified: comdev/helpwanted.apache.org/site/js/hw.js
URL: http://svn.apache.org/viewvc/comdev/helpwanted.apache.org/site/js/hw.js?rev=1755615&r1=1755614&r2=1755615&view=diff
==============================================================================
--- comdev/helpwanted.apache.org/site/js/hw.js (original)
+++ comdev/helpwanted.apache.org/site/js/hw.js Tue Aug 9 15:12:57 2016
@@ -456,7 +456,7 @@ function populateAdminForm() {
}
function displayItems(json, state) {
- json = json ? json : cjson
+ json = json ? json.tasks : cjson
cjson = json
var numItems = 0
for (var i in json) {
@@ -519,10 +519,10 @@ function displayItems(json, state) {
add = " <a href='/admin/close.lua?id=" + item.request_id + "'>Mark as done</a>"
}
item.description = item.description.replace(/\n/g, "<br/>").replace(hw_weburl, function(a) { return "<a href='"+a+"'>"+a+"</a>"})
- tbl += "<tr style='cursor: pointer;' onclick=\"sw('details_" + i + "');\"><td width='68'><div class='itemNumber-yellow'>" + z + "</div><img title='" + item.type + "' style='float: left; width: 24px; height: 24px;' src='images/icon_" + ptype + ".png'/></td>" +
+ tbl += "<tr style='cursor: pointer;' onclick=\"sw('details_" + i + "');\"><td width='68'><div class='itemNumber-yellow'>" + z + "</div><img title='" + item.type + "' style='float: left; width: 24px; height: 24px;' src='https://helpwanted.apache.org/images/icon_" + ptype + ".png'/></td>" +
"<td>" + item.project + "</td>"+
"<td style='text-align: left;'>" + item.title + "</td>" +
- "<td>" + lingos + "</td><td title='" + diff_explanation[parseInt(item.difficulty)] + "' style='text-align: left;'><img style='width: 20px; height: 20px; vertical-align: middle;' src='images/level_" + (parseInt(item.difficulty)+1) + ".png'/> " + diff[item.difficulty] + add + "</td><td>" + cdate + "</td></tr>"
+ "<td>" + lingos + "</td><td title='" + diff_explanation[parseInt(item.difficulty)] + "' style='text-align: left;'><img style='width: 20px; height: 20px; vertical-align: middle;' src='https://helpwanted.apache.org/images/level_" + (parseInt(item.difficulty)+1) + ".png'/> " + diff[item.difficulty] + add + "</td><td>" + cdate + "</td></tr>"
tbl += "<tr style='display:none;' id='details_" + i + "'><td colspan='6'><b>Project:</b> " + item.project + "<br/><b>Requested by:</b> " + item.author + "@apache.org<br/><b>Created:</b> " + cdate + "<br/><b>Description:</b> <blockquote>" + item.description + "</blockquote><b>Further information: </b> <a href='" + item.url + "'>" + item.url + "</a><br/><input type='button' onclick='location.href=\"https://helpwanted.apache.org/task.html?" + item.request_id +"\";' value='I am interested in this'/></td></tr>"
@@ -539,7 +539,7 @@ function fetchItems(languages, types, pr
if (!languages) languages = []
if (!types) types = []
if (!projects) projects = []
- getAsyncJSON("https://helpwanted.apache.org/listitems.lua?lang=" + languages.join(",") + "&type=" + types.join(",") +"&project=" + projects.join(","),
+ getAsyncJSON("https://helpwanted.apache.org/tasks.lua?lang=" + languages.join(",") + "&type=" + types.join(",") +"&project=" + projects.join(","),
{
languages: languages,
types: types,
@@ -551,7 +551,7 @@ function fetchItems(languages, types, pr
function fetchItemsAdmin() {
- getAsyncJSON("https://helpwanted.apache.org/listitems.lua", {admin: true}, displayItems)
+ getAsyncJSON("https://helpwanted.apache.org/tasks.lua", {admin: true}, displayItems)
}
function renderItem(json, state) {
@@ -588,5 +588,5 @@ function renderItem(json, state) {
}
function displayItem(id) {
- getAsyncJSON("https://helpwanted.apache.org/listitems.lua?id=" + id, id, renderItem)
+ getAsyncJSON("https://helpwanted.apache.org/tasks.lua?id=" + id, id, renderItem)
}
\ No newline at end of file
Modified: comdev/helpwanted.apache.org/site/listitems.lua
URL: http://svn.apache.org/viewvc/comdev/helpwanted.apache.org/site/listitems.lua?rev=1755615&r1=1755614&r2=1755615&view=diff
==============================================================================
--- comdev/helpwanted.apache.org/site/listitems.lua (original)
+++ comdev/helpwanted.apache.org/site/listitems.lua Tue Aug 9 15:12:57 2016
@@ -86,7 +86,7 @@ function handle(r)
dsl = ("%s AND tag:(%s)"):format(dsl, ta)
end
- local doc = elastic.find(dsl, 200, 'item', 'created')
+ local doc = elastic.find(dsl, 250, 'item', 'created')
if doc and #doc > 0 then
if not get.all then
local vdoc = {}
Added: comdev/helpwanted.apache.org/site/tasks.lua
URL: http://svn.apache.org/viewvc/comdev/helpwanted.apache.org/site/tasks.lua?rev=1755615&view=auto
==============================================================================
--- comdev/helpwanted.apache.org/site/tasks.lua (added)
+++ comdev/helpwanted.apache.org/site/tasks.lua Tue Aug 9 15:12:57 2016
@@ -0,0 +1,152 @@
+--[[
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+]]--
+
+local JSON = require 'cjson'
+local elastic = require 'lib/elastic'
+local cache = {}
+
+function handle(r)
+ r.content_type = "application/json"
+ local t = {}
+ local now = r:clock()
+ local tnow = now
+ local get = r:parseargs()
+ local qs = "*"
+ local domain = get.domain or ""
+ if #domain < 2 then
+ domain = "*"
+ end
+ local dd = 14
+ local maxresults = 10000
+ local listdata = {}
+
+ if get.id then
+ local doc = nil
+ if #get.id == 8 and get.id:match("^([a-f0-9]+)$") then
+ docs = elastic.find('_id:' .. get.id .. "*", 1, 'item', 'created')
+ if docs and #docs == 1 then
+ doc = docs[1]
+ end
+ else
+ doc = elastic.get('item', get.id)
+ end
+ if doc then
+ r:puts(JSON.encode(doc))
+ return apache2.OK
+ end
+ r:puts[[{}]]
+ return apache2.OK
+ end
+
+ -- Languages
+ local lingos = {}
+ for lang in (get.lang or ""):gmatch("([+#A-Za-z0-9+]+)") do
+ table.insert(lingos, lang)
+ end
+
+ -- Types
+ local types = {}
+ for typ in (get.type or ""):gmatch("([+#A-Za-z0-9+]+)") do
+ table.insert(types, typ)
+ end
+
+ -- Projects
+ local projects = {}
+ for project in (get.project or ""):gmatch("([+#A-Za-z0-9+]+)") do
+ table.insert(projects, project)
+ end
+
+ -- Tags
+ local tags = {}
+ for tag in (get.tags or ""):gmatch("([+#A-Za-z0-9+]+)") do
+ table.insert(tags, tag)
+ end
+
+ local wcards = nil
+ if #projects == 0 then
+ wcards = {project = "*"}
+ end
+ local mpl = #projects > 0 and { match = {project = { query = table.concat(projects, " ")}}} or nil
+ local mtl = #types > 0 and { match = {['type'] = { query = table.concat(types, " ")}}} or nil
+ local mll = #lingos > 0 and { match = { languages = {query = table.concat(lingos, " ")}}} or nil
+ local mta = #tags > 0 and { match = { tags = {query = table.concat(tags, " ")}}} or nil
+
+ local matches = {}
+ if mpl then table.insert(matches,mpl) end
+ if mtl then table.insert(matches,mtl) end
+ if mll then table.insert(matches,mll) end
+ if mta then table.insert(matches,mta) end
+
+ if not (mpl or mtl or mll or mta) then
+ matches = nil
+ end
+
+
+ -- First, check cache for recent dsl-alike
+ local ts = os.time()
+ local dsl = r:sha1(JSON.encode({matches, wcards}))
+ local doc = {}
+ local fc = false
+ for k, v in pairs(cache) do
+ if v.dsl == dsl and v.timestamp > (ts - 120) then
+ fc = true
+ doc = v.cache
+ break
+ end
+ end
+ if not fc then
+ doc = elastic.raw {
+ query = {
+ bool = {
+ must = matches,
+ }
+ },
+
+ sort = {
+ {
+ created = {
+ order = "desc"
+ }
+ }
+ },
+ size = 250
+ }
+ end
+
+ local vdoc = {}
+ if doc and doc.hits and doc.hits.hits and #doc.hits.hits > 0 then
+ for k, v in pairs(doc.hits.hits) do
+ if not v._source.closed or get.all then
+ v._source.request_id = v._id
+ table.insert(vdoc, v._source)
+ end
+ end
+ if not fc then
+ table.insert(cache, {
+ dsl = dsl,
+ timestamp = ts,
+ cache = doc
+ })
+ if #cache > 50 then
+ cache[1] = nil
+ end
+ end
+ end
+ r:puts(JSON.encode({cached = fc, num = #vdoc, took = ((r:clock()-now)/1000), tasks = vdoc, dsl = dsl}))
+ return apache2.OK
+end
Modified: comdev/helpwanted.apache.org/site/widget.js
URL: http://svn.apache.org/viewvc/comdev/helpwanted.apache.org/site/widget.js?rev=1755615&r1=1755614&r2=1755615&view=diff
==============================================================================
--- comdev/helpwanted.apache.org/site/widget.js (original)
+++ comdev/helpwanted.apache.org/site/widget.js Tue Aug 9 15:12:57 2016
@@ -113,7 +113,7 @@ function displayItemsWidget(json, state,
}
}
var hwuid = obj.getAttribute("hwuid")
- hw_json[hwuid] = json ? json : hw_json[hwuid]
+ hw_json[hwuid] = json ? json.tasks : hw_json[hwuid]
json = hw_json[hwuid]
var diff = ['Beginner', 'Journeyman', 'Intermediate', 'Advanced', 'Expert']
var numItems = 0
@@ -200,7 +200,7 @@ function fetchItemsWidget(languages, typ
if (!types) types = []
if (!projects) projects = []
if (!tags) tags = []
- getAsyncJSON("https://helpwanted.apache.org/listitems.lua?lang=" + languages.join(",") + "&type=" + types.join(",") +"&project=" + projects.join(",") +"&tags=" + tags.join(","),
+ getAsyncJSON("https://helpwanted.apache.org/tasks.lua?lang=" + languages.join(",") + "&type=" + types.join(",") +"&project=" + projects.join(",") +"&tags=" + tags.join(","),
{
languages: languages,
types: types,
Modified: comdev/helpwanted.apache.org/site/wtest.html
URL: http://svn.apache.org/viewvc/comdev/helpwanted.apache.org/site/wtest.html?rev=1755615&r1=1755614&r2=1755615&view=diff
==============================================================================
--- comdev/helpwanted.apache.org/site/wtest.html (original)
+++ comdev/helpwanted.apache.org/site/wtest.html Tue Aug 9 15:12:57 2016
@@ -19,9 +19,9 @@
<p>Projects can also search the entire foundation task list, or use tags:</p>
<pre style='background: #FFE; border: 1px solid #666;'>
-<div style="width: 700px;" type="helpwanted" project="*" tags="hackillinois" description="the Apache Software Foundation"></div>
+<div style="width: 700px;" type="helpwanted" project="*" tags="GSoC" description="the Apache Software Foundation"></div>
<script src="https://helpwanted.apache.org/widget.js" type="text/javascript"></script></pre>
- <div id="foo2" style="width: 700px;" type="helpwanted" project="*" tags="hackillinois" description="the Apache HTTP Server"></div>
+ <div id="foo2" style="width: 700px;" type="helpwanted" project="*" tags="GSoC" description="the Apache HTTP Server"></div>
<script type="text/javascript">