Index: openacs-4/packages/download/sql/postgresql/download-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/download/sql/postgresql/download-create.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/download/sql/postgresql/download-create.sql 14 May 2001 20:31:08 -0000 1.2 +++ openacs-4/packages/download/sql/postgresql/download-create.sql 16 May 2001 09:41:05 -0000 1.3 @@ -215,6 +215,11 @@ -- vendor (via metadata) -- owner (via metadata) +-- not sure where most of the above stuff is, +-- but I added file_size, cuz the oracle version +-- keeps content in blobs and thus can easily +-- get file_size from the database +-- vinodk 2001-05-16 create table download_archive_revisions ( revision_id integer constraint download_ar_id_fk @@ -226,10 +231,29 @@ approved_user integer constraint download_ar_usr_fk references users, - approved_comment varchar(1000) + approved_comment varchar(1000), + file_size integer + constraint download_ar_file_size_nn + not null ); +-- added table download_archive_descs - vinodk +-- Normally this table is created during content_type__create_type +-- but it only contains the primary key +-- I want it to also contain file_size, since the oracle version +-- calculates file_size in the database. +--create table download_archive_descs ( +-- archive_desc_id integer +-- constraint download_ar_desc_id_fk +-- references cr_items (item_id) on delete cascade +-- constraint download_ar_desc_id_pk +-- primary key, +-- file_size integer +-- constraint download_ar_desc_fs_nn +-- not null +--); + -- Storage of the metadata per archive -- Long skinny table. create table download_revision_data ( Index: openacs-4/packages/download/sql/postgresql/download-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/download/sql/postgresql/download-drop.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/download/sql/postgresql/download-drop.sql 14 May 2001 20:31:08 -0000 1.3 +++ openacs-4/packages/download/sql/postgresql/download-drop.sql 16 May 2001 09:41:05 -0000 1.4 @@ -2,6 +2,27 @@ -- Drop the data model and the PL/SQL packages. -- +-- Views -- +drop view download_repository_obj; +drop view download_archives_obj; +drop view download_arch_revisions_obj; +drop view download_downloads_repository; + +-- Sequences -- +drop sequence download_archive_type_seq; +drop view download_archive_type_sequence; +drop sequence download_reasons_seq; +drop view download_reasons_sequence; +drop sequence download_md_choice_id_seq; +drop view download_md_choice_id_sequence; +drop sequence download_downloads_seq; +drop view download_downloads_sequence; + +-- Functions -- +drop function download_rep__new (integer,varchar,varchar,varchar,timestamp,integer,integer,integer,varchar); +drop function download_rep__edit (integer,varchar,varchar,varchar,timestamp,integer,varchar); +drop function download_rep__delete (integer); + /* Drop all content items */ create function inline_0 () @@ -14,9 +35,9 @@ where content_type in ( ''cr_download_archive_desc'', ''cr_download_archive'', ''cr_download_rep'' ) loop - for archive_child_rec in select * from acs_object_context_index where ancestor_id = archive_rec.item_id loop - PERFORM content_item__delete( archive_child_rec.object_id ); - end loop; +-- for archive_child_rec in select * from acs_object_context_index where ancestor_id = archive_rec.item_id loop +-- PERFORM content_item__delete( archive_child_rec.object_id ); +-- end loop; PERFORM content_item__delete( archive_rec.item_id ); end loop; @@ -51,22 +72,6 @@ --end; --/ -/* Sequences */ -drop sequence download_archive_type_seq; -drop view download_archive_type_sequence; -drop sequence download_reasons_seq; -drop view download_reasons_sequence; -drop sequence download_md_choice_id_seq; -drop view download_md_choice_id_sequence; -drop sequence download_downloads_seq; -drop view download_downloads_sequence; - -/* Views */ -drop view download_repository_obj; -drop view download_archives_obj; -drop view download_arch_revisions_obj; -drop view download_downloads_repository; - /* Tables */ drop table download_downloads; drop table download_revision_data; @@ -165,8 +170,4 @@ --show errors -- -drop function download_rep__new (integer,varchar,varchar,varchar,timestamp,integer,integer,integer,varchar); -drop function download_rep__edit (integer,varchar,varchar,varchar,timestamp,integer,varchar); -drop function download_rep__delete (integer); - --drop package download_rep; Index: openacs-4/packages/download/tcl/download-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/download/tcl/download-procs-postgresql.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/download/tcl/download-procs-postgresql.xql 14 May 2001 20:31:42 -0000 1.3 +++ openacs-4/packages/download/tcl/download-procs-postgresql.xql 16 May 2001 09:41:05 -0000 1.4 @@ -61,8 +61,8 @@ :creation_ip ); - insert into download_archive_revisions (revision_id, approved_p) values - (v_revision_id, :approved_p); + insert into download_archive_revisions (revision_id, approved_p, file_size) values + (v_revision_id, :approved_p, :file_size); return v_revision_id; end; Index: openacs-4/packages/download/tcl/download-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/download/tcl/download-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/download/tcl/download-procs.tcl 11 May 2001 05:20:45 -0000 1.2 +++ openacs-4/packages/download/tcl/download-procs.tcl 16 May 2001 09:41:05 -0000 1.3 @@ -336,6 +336,9 @@ set filename $upload_file } + # get the file_size for the postgres version + set file_size [file size $upload_file] + set mime_type [download_maybe_create_new_mime_type $upload_file] db_exec_plsql revision_new { declare Index: openacs-4/packages/download/www/download-verify-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/download/www/download-verify-oracle.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/download/www/download-verify-oracle.xql 10 May 2001 20:51:30 -0000 1.1 +++ openacs-4/packages/download/www/download-verify-oracle.xql 16 May 2001 09:41:05 -0000 1.2 @@ -13,7 +13,7 @@ dar.revision_id, dar.file_name, dar.version_name, - dbms_lob.getlength(dar.content) as file_size + round(dbms_lob.getlength(dar.content)/1024) as file_size from download_archives_obj da, download_arch_revisions_obj dar where da.archive_id = dar.archive_id and Index: openacs-4/packages/download/www/download-verify-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/download/www/download-verify-postgresql.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/download/www/download-verify-postgresql.xql 11 May 2001 05:20:45 -0000 1.2 +++ openacs-4/packages/download/www/download-verify-postgresql.xql 16 May 2001 09:41:05 -0000 1.3 @@ -13,7 +13,7 @@ dar.revision_id, dar.file_name, dar.version_name, - dar.content as content_path + dar.file_size / 1024 as file_size from download_archives_obj da, download_arch_revisions_obj dar where da.archive_id = dar.archive_id and Index: openacs-4/packages/download/www/download-verify.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/download/www/download-verify.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/download/www/download-verify.adp 20 Apr 2001 20:51:10 -0000 1.1 +++ openacs-4/packages/download/www/download-verify.adp 16 May 2001 09:41:05 -0000 1.2 @@ -6,7 +6,7 @@ - + <%= [export_form_vars download_id revision_id] %> Index: openacs-4/packages/download/www/download-verify.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/download/www/download-verify.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/download/www/download-verify.tcl 14 May 2001 20:31:42 -0000 1.3 +++ openacs-4/packages/download/www/download-verify.tcl 16 May 2001 09:41:05 -0000 1.4 @@ -39,15 +39,6 @@ return } -# oracle version gets file_size from the blob -# postgres version can't (content is in fs, not db), -# so it gets content_path -# and we can calculate file_size here - -if { ![info exists file_size] } { - set file_size [cr_file_size $content_path] -} - set context_bar [list [list "one-archive?archive_id=$archive_id" $archive_name] "Download $archive_name $version_name"] ##TODO Get version name Index: openacs-4/packages/download/www/index-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/download/www/index-oracle.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/download/www/index-oracle.xql 16 May 2001 02:22:16 -0000 1.3 +++ openacs-4/packages/download/www/index-oracle.xql 16 May 2001 09:41:05 -0000 1.4 @@ -32,7 +32,7 @@ dar.revision_id, dar.file_name, dar.version_name, - dbms_lob.getlength(dar.content) as file_size, + round(dbms_lob.getlength(dar.content)/1024) as file_size, (select count(*) from download_downloads where revision_id = dar.revision_id) as downloads, dar.approved_p $metadata_selects @@ -57,12 +57,28 @@ - + - sysdate + dar.publish_date + 1 > sysdate + + + + dar.publish_date + 7 > sysdate + + + + + + + + dar.publish_date + 30 > sysdate + + + + Index: openacs-4/packages/download/www/index-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/download/www/index-postgresql.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/download/www/index-postgresql.xql 16 May 2001 02:21:33 -0000 1.3 +++ openacs-4/packages/download/www/index-postgresql.xql 16 May 2001 09:41:05 -0000 1.4 @@ -32,7 +32,7 @@ dar.revision_id, dar.file_name, dar.version_name, - dar.content as file_size, + dar.file_size / 1024 as file_size, (select count(*) from download_downloads where revision_id = dar.revision_id) as downloads, dar.approved_p $metadata_selects @@ -57,12 +57,28 @@ - + - current_timestamp + dar.publish_date + '1 days'::interval > current_timestamp + + + + dar.publish_date + '7 days'::interval > current_timestamp + + + + + + + + dar.publish_date + '30 days'::interval > current_timestamp + + + + Index: openacs-4/packages/download/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/download/www/index.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/download/www/index.tcl 16 May 2001 02:28:46 -0000 1.3 +++ openacs-4/packages/download/www/index.tcl 16 May 2001 09:41:05 -0000 1.4 @@ -8,6 +8,7 @@ {archive_type_id ""} {orderby "archive_name"} {query_string ""} + {updated ""} } -properties { title:onevalue description:onevalue @@ -28,12 +29,13 @@ set help_text $repository(help_text) #select the current list of archives -set type_dimlist {{"" "All" {}}} +set type_dimlist {} db_foreach archive_type { select archive_type_id as at_id, pretty_name from download_archive_types where repository_id = :repository_id } { lappend type_dimlist [list $at_id $pretty_name [list where "da.archive_type_id = $at_id"]] } +lappend type_dimlist {"" "all" {}} set dimensional [list \ {versions "Versions" current { @@ -42,9 +44,9 @@ }} \ [list archive_type_id "Type" "" $type_dimlist] \ {updated "Updated" all { - {1d "last 24hrs" {where "dar.publish_date + 1 > [db_map date_clause]"}} - {1w "last week" {where "dar.publish_date + 7 > [db_map date_clause]"}} - {1m "last month" {where "dar.publish_date + 30 > [db_map date_clause]"}} + {1d "last 24hrs" {where "[db_map date_clause_1]"}} + {1w "last week" {where "[db_map date_clause_7]"}} + {1m "last month" {where "[db_map date_clause_30]"}} {all "all" {}} }} \ ] @@ -61,12 +63,10 @@ set approval " and dar.approved_p = 't' " } -#FIXME fix the file size thing - set table_def { {archive_name "Software Name" {lower(archive_name) $order} - {}} + {}} {archive_type "Software Type" {} {}} {downloads "# Downloads" {} {}} } Index: openacs-4/packages/download/www/one-revision-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/download/www/one-revision-oracle.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/download/www/one-revision-oracle.xql 10 May 2001 20:51:30 -0000 1.1 +++ openacs-4/packages/download/www/one-revision-oracle.xql 16 May 2001 09:41:05 -0000 1.2 @@ -17,7 +17,7 @@ dar.file_name, dar.version_name, dar.version_name, - dbms_lob.getlength(dar.content) as file_size, + round(dbms_lob.getlength(dar.content) / 1024) as file_size, (select count(*) from download_downloads where revision_id = dar.revision_id) as downloads, dar.approved_p, u.last_name || ', ' || u.first_names as creation_user_name, Index: openacs-4/packages/download/www/one-revision-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/download/www/one-revision-postgresql.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/download/www/one-revision-postgresql.xql 11 May 2001 05:20:45 -0000 1.2 +++ openacs-4/packages/download/www/one-revision-postgresql.xql 16 May 2001 09:41:05 -0000 1.3 @@ -17,7 +17,7 @@ dar.file_name, dar.version_name, dar.version_name, - dar.content as content_path, + dar.file_size / 1024 as file_size, (select count(*) from download_downloads where revision_id = dar.revision_id) as downloads, dar.approved_p, u.last_name || ', ' || u.first_names as creation_user_name, Index: openacs-4/packages/download/www/one-revision.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/download/www/one-revision.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/download/www/one-revision.tcl 11 May 2001 05:20:45 -0000 1.2 +++ openacs-4/packages/download/www/one-revision.tcl 16 May 2001 09:41:05 -0000 1.3 @@ -68,15 +68,6 @@ return } -# oracle version gets file_size from the blob -# postgres version can't (content is in fs, not db), -# so it gets content_path -# and we can calculate file_size here - -if { ![info exists file_size] } { - set file_size [cr_file_size $content_path] -} - set description [acs_messaging_format_as_html $description_type $description] set context_bar [list [list "one-archive?archive_id=$archive_id" $archive_name] "$archive_name $version_name"] Index: openacs-4/packages/download/www/admin/approve-or-reject-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/download/www/admin/approve-or-reject-postgresql.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/download/www/admin/approve-or-reject-postgresql.xql 11 May 2001 05:20:45 -0000 1.2 +++ openacs-4/packages/download/www/admin/approve-or-reject-postgresql.xql 16 May 2001 09:41:05 -0000 1.3 @@ -12,7 +12,7 @@ dar.revision_id, dar.file_name, dar.version_name, - dar.content as content_path, + dar.file_size as file_size, case when da.latest_revision = dar.revision_id then 't' else 'f' end as current_version_p, dar.creation_user, dar.creation_date, Index: openacs-4/packages/download/www/admin/approve-or-reject.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/download/www/admin/approve-or-reject.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/download/www/admin/approve-or-reject.tcl 11 May 2001 05:20:45 -0000 1.2 +++ openacs-4/packages/download/www/admin/approve-or-reject.tcl 16 May 2001 09:41:05 -0000 1.3 @@ -41,16 +41,6 @@ return } -# oracle version gets file_size from the blob -# postgres version can't (content is in fs, not db), -# so it gets content_path -# and we can calculate file_size here - -if { ![info exists file_size] } { - set file_size [cr_file_size $content_path] -} - - if { $action == "approve" } { set pretty_action "Approve" set pretty_noun "Approval"
File Size:<%= [expr $file_size / 1024]%>k@file_size@k
 $archive_name $version_name  ([expr [cr_file_size $file_size] / 1024]k)
$summary
 $archive_name $version_name  (${file_size}k)
$summary