% Option Explicit %>
<%
' TO DO:
'
' - JobFightServlet.java so you can actually do a jobfight online
' - Last set of figures as well as total/avg
Const LANG = 0
Const AVG = 1
Const TOTAL = 2
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' Main
'
' Purpose:
'
' Directs the action.
'
' Revisions:
'
' [TDB 09.Jul.2003] Code written.
' [bakert@gmail.com 2005-04-26] Comments added.
' [bakert@gmail.com 2005-05-01] Added iframe that points at jobfight.jsp.
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub Main()
Call WriteStandardHeader("JobFight! - Like Googlefight only " & _
"with jobserve", "Comparison of the popularity of " & _
"different skills on jobserve.com over time", _
"jobs, keywords, skills, programming languages")
%>
JobFight!
|
|
Enter two skill keywords (for example, "Java" and "C#")
to find out which has more jobs.
|
Past Statistics
<% Call PastStats()
Call WriteStandardFooter()
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' JobFight
'
' Purpose:
'
' Reads the jobfight file and displays the results.
'
' Revisions:
'
' [TDB 09.Jul.2003] Code written.
' [bakert@gmail.com 2005-04-26] Comments added.
' [bakert@gmail.com 2005-05-01] Renamed from "JobFight" to "PastStats" to
' reflect what this routine really shows.
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub PastStats()
Const LOG = "c:\java\jobfight\jobfight.txt"
Const READ = 1
Dim objFS, objFile, strLine, objTextStream, objDict, intCount, strLang, _
intTotal, intTotalVisits, strKey, dtmFirstDate, dtmLastDate, _
arrOrdered, intIndex, objFirstAppeared, objVisits, intVisits, _
objLast
Set objFS = Server.CreateObject("Scripting.FileSystemObject")
If Not objFS.FileExists(LOG) Then
Response.Write "Log file cannot be found at this time - " & _
" please let me know at " & ADMIN_EMAIL_ & ".
" & vbCrLf
Exit Sub
End If
Set objDict = Server.CreateObject("Scripting.Dictionary")
Set objFirstAppeared = Server.CreateObject("Scripting.Dictionary")
Set objVisits = Server.CreateObject("Scripting.Dictionary")
Set objLast = Server.CreateObject("Scripting.Dictionary")
Set objFile = objFS.GetFile(LOG)
Set objTextStream = objFile.OpenAsTextStream(READ, -2)
While Not objTextStream.AtEndOfStream
strLine = objTextStream.ReadLine()
If IsDate(strLine) Then
If intVisits = 0 Then
dtmFirstDate = CDate(strLine)
End If
dtmLastDate = CDate(strLine)
intTotalVisits = intTotalVisits + 1
Else
intCount = ParseCount(strLine)
strLang = ParseLang(strLine)
If objDict.Exists(strLang) Then
intTotal = objDict.Item(strLang) + intCount
objDict.Remove strLang
intVisits = objVisits.Item(strLang) + 1
objVisits.Remove(strLang)
objLast.Remove strLang
Else
intTotal = intCount
objFirstAppeared.Add strLang, _
FormatDate_ddMMMyyyy(dtmLastDate, True)
intVisits = 1
End If
objDict.Add strLang, intTotal
objVisits.Add strLang, intVisits
objLast.Add strLang, intCount
End If
Wend
Response.Write "Displaying totals from " & intTotalVisits & _
" visits to jobserve from " & _
FormatDate_ddMMMyyyy(dtmFirstDate, True) & _
" to " & FormatDate_ddMMMyyyy(dtmLastDate, True) & "
"
' Should last individual totals as well
arrOrdered = GetOrderedArray(objDict, objVisits)
Response.Write "" & vbCrLf
Response.Write "Language | Average Jobs | " & _
"Jobs on Last Visit | " & _
"Counting Since | Samples | Total Jobs |
" & _
vbCrLf
For intIndex = LBound(arrOrdered) To UBound(arrOrdered)
Response.Write "" & _
"" & _
"" & _
arrOrdered(intIndex, LANG) & "" & _
" | " & _
FormatNumber(arrOrdered(intIndex, AVG), 2) & _
" | " & _
"" & _
FormatNumber(objLast.Item(arrOrdered(intIndex, LANG)), 0) & _
" | " & _
"" & objFirstAppeared(arrOrdered(intIndex, LANG)) & _
" | " & _
objVisits(arrOrdered(intIndex, LANG)) & " | " & _
"" & _
arrOrdered(intIndex, TOTAL) & " |
" & vbCrLf
Next
Response.Write "
" & vbCrLf
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' GetOrderedArray
'
' Gets an ordered array containing language name, average jobs on a visit and
' total number of jobs from a dictionary of totals and a dictionary of number
' of visits indexed by language.
'
' Parameters:
'
' objDict - Dictionary of name=>total jobs pairs.
' objVisits - Dictionary of name=>total visits pairs.
'
' Returns:
'
' Ordered 2d array with highest average number of jobs first in with name,
' average and total visits in each row of the array.
'
' Revisions:
'
' [TDB 09.Jul.2003] Code written.
' [bakert@gmail.com 2005-04-26] Comments added.
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function GetOrderedArray(objDict, objVisits)
Dim arrOrdered, strKey, strHighKey, intIndex, dblHigh, dblAvg
ReDim arrOrdered(objDict.Count - 1, 3)
dblHigh = -1.0
Do Until objDict.Count = 0
For Each strKey In objDict.Keys
dblAvg = CDbl(objDict.Item(strKey) / objVisits.Item(strKey))
If (dblAvg > dblHigh) Then
dblHigh = dblAvg
strHighKey = strKey
End If
Next
arrOrdered(intIndex, LANG) = strHighKey
arrOrdered(intIndex, AVG) = _
objDict.Item(strHighKey) / objVisits.Item(strHighKey)
arrOrdered(intIndex, TOTAL) = objDict.Item(strHighKey)
objDict.Remove(strHighKey)
dblHigh = -1.0
If intIndex > UBound(arrOrdered) Then
Response.Write "Err"
GetOrderedArray = arrOrdered
Exit Function
End If
intIndex = intIndex + 1
Loop
GetOrderedArray = arrOrdered
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' ParseCount
'
' Purpose:
'
' Parses the number from a String from the jobfight file.
'
' Parameters:
'
' strText - Line to parse.
'
' Returns:
'
' Number, or 0 if no number can be parsed.
'
' Revisions:
'
' [TDB 09.Jul.2003] Code written.
' [bakert@gmail.com 2005-04-26] Comments added.
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function ParseCount(strText)
Dim arrCount
arrCount = Split(strText, " ")
If IsNumeric(arrCount(0)) Then
ParseCount = CDbl(arrCount(0))
Else
ParseCount = 0
End If
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' ParseLang
'
' Parses the language name from a line of the jobfight file.
'
' Parameters:
'
' strText - String to parse.
'
' Returns:
'
' Language name.
'
' Revisions:
'
' [TDB 09.Jul.2003] Code written.
' [bakert@gmail.com 2005-04-26] Comments added.
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function ParseLang(strText)
Dim intStart
intStart = InStr(strText, " ")
ParseLang = Mid(strText, intStart, Len(strText) - intStart + 1)
End Function
Call Main()
%>