Changeset 3488
- Timestamp:
- 07/17/08 15:06:23 (4 months ago)
- Files:
-
- trunk/projects/bos/m2/m2.lisp (modified) (4 diffs)
- trunk/projects/bos/m2/packages.lisp (modified) (1 diff)
- trunk/projects/bos/web/kml-handlers.lisp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/projects/bos/m2/m2.lisp
r3486 r3488 592 592 (sold-m2s 0) 593 593 (paying-sponsors 0) 594 (country-sponsors (make-hash-table :test #'equal))594 (country-sponsors (make-hash-table)) 595 595 (last-contracts (make-list +last-contracts-cache-size+))) 596 596 … … 604 604 (sponsor (contract-sponsor contract)) 605 605 (new-sponsor-p (alexandria:length= 1 (sponsor-contracts sponsor))) 606 (%country (sponsor-country sponsor)) 607 (country (and %country (string-upcase %country)))) 606 (country (sponsor-country sponsor))) 608 607 (with-slots (sold-m2s paying-sponsors country-sponsors last-contracts) 609 608 *contract-stats* … … 632 631 633 632 (defun contract-stats-for-country (country) 633 (assert (keywordp country)) 634 634 (let ((stat (gethash country (contract-stats-country-sponsors *contract-stats*)))) 635 635 (if stat … … 644 644 (contract-stats-last-contracts *contract-stats*))) 645 645 646 (defun invoke-with-countries (function as-keyword) 647 (alexandria:maphash-keys 648 (if as-keyword 649 (lambda (country) (funcall function (make-keyword-from-string country))) 650 function) 651 (contract-stats-country-sponsors *contract-stats*))) 652 653 (defmacro do-countries ((country &key as-keyword) &body body) 646 (defun invoke-with-countries (function) 647 (alexandria:maphash-keys function (contract-stats-country-sponsors *contract-stats*))) 648 649 (defmacro do-sponsor-countries ((country) &body body) 654 650 (check-type country symbol) 655 `(invoke-with-countries (lambda (,country) ,@body) ,as-keyword))651 `(invoke-with-countries (lambda (,country) ,@body))) 656 652 657 653 (register-store-transient-init-function 'initialize-contract-stats) trunk/projects/bos/m2/packages.lisp
r3486 r3488 171 171 #:contract-stats-for-country 172 172 #:last-paid-contracts 173 #:do- countries173 #:do-sponsor-countries 174 174 175 175 #:make-m2-javascript trunk/projects/bos/web/kml-handlers.lisp
r3467 r3488 155 155 (with-element "Icon" 156 156 ;; (with-element "href" (text "http://maps.google.com/mapfiles/kml/pal3/icon23.png")) 157 (with-element "href" (text (format nil "http://~a/static/Orang_weiss.png" (website-host))))))) 158 (dolist (country-contracts (sort (group-on (remove-if-not #'contract-paidp contracts) 159 :test #'equal 160 :key (lambda (contract) 161 (string-upcase (sponsor-country (contract-sponsor contract))))) 162 #'> :key (lambda (entry) (length (cdr entry))))) 163 (let ((coords (cdr (assoc (make-keyword-from-string (car country-contracts)) *country-coords*)))) 157 (with-element "href" (text (format nil "http://~a/static/Orang_weiss.png" (website-host))))))) 158 (do-sponsor-countries (country) 159 (let ((coords (cdr (assoc country *country-coords*)))) 164 160 (when coords 165 161 (destructuring-bind (lon lat) 166 162 coords 167 ( let* ((contracts (cdr country-contracts))168 (number-contracts (length contracts)))163 (multiple-value-bind (number-of-paying-sponsors number-of-sold-m2s) 164 (contract-stats-for-country country) 169 165 (with-element "Placemark" 170 166 ;; (with-element "name" (text (format nil "~a ~a" (car country-contracts) (length (cdr country-contracts))))) … … 175 171 (dictionary-entry "BOS says thank you to all sponsors!" lang) 176 172 (dictionary-entry 177 (second (assoc (make-keyword-from-string (car country-contracts))*country-english-names*)) lang)178 number- contracts179 (if (= 1 number- contracts)173 (second (assoc country *country-english-names*)) lang) 174 number-of-paying-sponsors 175 (if (= 1 number-of-paying-sponsors) 180 176 (dictionary-entry "sponsor" lang) 181 177 (dictionary-entry "sponsors" lang)) 182 178 (dictionary-entry "total contribution" lang) 183 (reduce #'+ contracts :key #'contract-area))))179 number-of-sold-m2s))) 184 180 (with-element "Point" 185 181 (with-element "coordinates"
