فهرست منبع

Merge branch 'laravel-migrate-wbw' of https://github.com/visuddhinanda/mint into laravel

bhikkhu-kosalla-china 4 سال پیش
والد
کامیت
08c0f6a859

+ 2 - 3
.env.example

@@ -57,8 +57,7 @@ MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
 
 RPC_SERVER="https://rpc.wikipali.org"
 ASSETS_SERVER="https://assets-hk.wikipali.org"
-HELP_SERVER="https://help-hk.wikipali.org"
-GRAMMAR_SERVER="https://grammar-hk.wikipali.org"
 
-SNOWFLAKE_DATACENTER_ID = 1
+
+SNOWFLAKE_DATA_CENTER_ID = 1
 SNOWFLAKE_WORKER_ID = 1

+ 44 - 4
app/Console/Commands/Install.php

@@ -11,7 +11,7 @@ class Install extends Command
      *
      * @var string
      */
-    protected $signature = 'install {--queue}';
+    protected $signature = 'install {--test}';
 
     /**
      * The console command description.
@@ -35,11 +35,51 @@ class Install extends Command
      *
      * @return int
      */
+	/*
+	php ../../public/app/install/db_insert_templet_cli.php 1 217
+	php ../../public/app/install/db_update_toc_cli.php 1 217 pali
+	php ../../public/app/install/db_update_toc_cli.php 1 217 zh-hans
+	php ../../public/app/install/db_update_toc_cli.php 1 217 zh-hant
+	php ../../public/app/install/db_insert_palitext_cli.php 1 217
+	php ../../public/app/install/db_update_palitext_cli.php 1 217
+	php ../../public/app/install/db_insert_bookword_from_csv_cli.php 1 217
+	php ../../public/app/install/db_insert_word_from_csv_cli.php 1 217
+	php ../../public/app/install/db_insert_wordindex_from_csv_cli.php
+
+	php ./migrations/20211202084900_init_pali_serieses.php
+	php ./migrations/20211125155600_word_statistics.php
+	php ./migrations/20211125155700_pali_sent_org.php
+	php ./migrations/20211125165700-pali_sent-upgrade.php
+	php ./migrations/20211126220400-pali_sent_index-upgrade.php
+	php ./migrations/20211127214800_sent_sim.php
+	php ./migrations/20211127214900-sent_sim_index.php
+
+	php ../../public/app/fts/sql.php
+
+	php ../../public/app/admin/word_index_weight_refresh.php 1 217
+	*/
     public function handle()
     {
-		$this->call('install:wbwtemplate', [
-			'from' => 1, 'to' => 217
-		]);
+		$isTest = $this->option('test');
+		if($isTest){
+			$this->call('install:wbwtemplate', ['from' => 1]);
+		}else{
+			$this->call('install:wbwtemplate');	
+			$this->call('install:palitext');	
+			$this->call('install:wordbook');	
+			$this->call('install:wordall');	
+			$this->call('install:wordindex');
+
+			$this->call('upgrade:palitext');	
+			$this->call('upgrade:palitoc',['lang'=>'pali']);	
+			$this->call('upgrade:palitoc',['lang'=>'zh-hans']);	
+			$this->call('upgrade:palitoc',['lang'=>'zh-hant']);	
+
+			$this->call('install:paliseries');	
+			$this->call('install:wordstatistics');	
+			
+		}
+
         return 0;
     }
 }

+ 29 - 31
app/Console/Commands/InstallPaliSeries.php

@@ -40,41 +40,39 @@ class InstallPaliSeries extends Command
      */
     public function handle()
     {
-		$this->info("upgrade pali text");
+		$this->info("upgrade pali serieses");
 		$startTime = time();
 
+		DB::transaction(function () {
+			#删除目标数据库中数据
+			BookTitle::where('book','>',0)->delete();
 
+		// 打开csv文件并读取数据										
+			$strFileName = config("app.path.pali_title") . "/pali_serieses.csv";
+			if(!file_exists($strFileName)){
+				return 1;
+			}		
+			$inputRow = 0;
+			if (($fp = fopen($strFileName, "r")) !== false) {
+				while (($data = fgetcsv($fp, 0, ',')) !== false) {
+					if($inputRow>0){
+						$newData = [
+							'book'=>$data[1],
+							'paragraph'=>$data[2],
+							'title'=>$data[3],
+						];
 
-					DB::transaction(function () {
-						#删除目标数据库中数据
-						BookTitle::where('book','>',0)->delete();
-
-					// 打开csv文件并读取数据										
-						$strFileName = config("app.path.pali_title") . "/pali_serieses.csv";
-						if(!file_exists($strFileName)){
-							return 1;
-						}						
-						$inputRow = 0;
-						if (($fp = fopen($strFileName, "r")) !== false) {
-							while (($data = fgetcsv($fp, 0, ',')) !== false) {
-								if($inputRow>0){
-									$newData = [
-										'book'=>$data[1],
-										'paragraph'=>$data[2],
-										'title'=>$data[3],
-									];
-		
-									BookTitle::create($newData);									
-								}
-								$inputRow++;
-							}
-							fclose($fp);
-							Log::info("res load:" .$strFileName);
-						} else {
-							$this->error("can not open csv $strFileName");
-							Log::error("can not open csv $strFileName");
-						}
-					});
+						BookTitle::create($newData);							
+					}
+					$inputRow++;
+				}
+				fclose($fp);
+				Log::info("res load:" .$strFileName);
+			} else {
+				$this->error("can not open csv $strFileName");
+				Log::error("can not open csv $strFileName");
+			}
+		});
 		$this->info("ok");
         return 0;
     }

+ 51 - 1
app/Console/Commands/InstallWordAll.php

@@ -3,6 +3,9 @@
 namespace App\Console\Commands;
 
 use Illuminate\Console\Command;
+use App\Models\WordList;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Log;
 
 class InstallWordAll extends Command
 {
@@ -11,7 +14,7 @@ class InstallWordAll extends Command
      *
      * @var string
      */
-    protected $signature = 'command:name';
+    protected $signature = 'install:wordall {from?} {to?}';
 
     /**
      * The console command description.
@@ -37,6 +40,53 @@ class InstallWordAll extends Command
      */
     public function handle()
     {
+		$startTime = time();
+
+		$this->info("instert word in palibook ");
+		Log::info("instert word in palibook ");
+
+		$_from = $this->argument('from');
+		$_to = $this->argument('to');
+		if(empty($_from) && empty($_to)){
+			$_from = 1;
+			$_to = 217;
+		}else if(empty($_to)){
+			$_to = $_from;
+		}
+
+		$bar = $this->output->createProgressBar($_to-$_from+1);
+
+		for ($book=$_from; $book <= $_to; $book++) { 
+			Log::info("doing ".($book));
+			DB::transaction(function ()use($book) {
+				$fileSn = $book-1;
+				if (($fpoutput = fopen(config("app.path.paliword_book") . "/{$fileSn}_words.csv", "r")) !== false){
+					#删除目标数据库中数据
+					WordList::where('book', $book)->delete();			
+					while (($data = fgetcsv($fpoutput, 0, ',')) !== false)  
+					{
+						$newData = [
+							'sn'=>$data[0],
+							'book'=>$data[1],
+							'paragraph'=>$data[2],
+							'wordindex'=>$data[3],
+							'bold'=>$data[4],
+						];
+						WordList::create($newData);				
+					}
+					return 0;			
+				}else{
+					Log::error("open csv fail");
+					return 1;
+				}
+			});
+			$bar->advance();
+		}
+		$bar->finish();
+
+		$msg = "all done in ". time()-$startTime . "s";
+		$this->info($msg.PHP_EOL);
+		Log::info($msg);
         return 0;
     }
 }

+ 45 - 1
app/Console/Commands/InstallWordIndex.php

@@ -3,6 +3,9 @@
 namespace App\Console\Commands;
 
 use Illuminate\Console\Command;
+use App\Models\WordIndex;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Log;
 
 class InstallWordIndex extends Command
 {
@@ -11,7 +14,7 @@ class InstallWordIndex extends Command
      *
      * @var string
      */
-    protected $signature = 'command:name';
+    protected $signature = 'install:wordindex';
 
     /**
      * The console command description.
@@ -37,6 +40,47 @@ class InstallWordIndex extends Command
      */
     public function handle()
     {
+		$startTime = time();
+
+		$info = "instert word in palibook ";
+		$this->info($info);
+		Log::info($info);
+
+		#删除目标数据库中数据
+		WordIndex::where('id', '>',-1)->delete();	
+
+		$scan = scandir(config("app.path.paliword_index"));
+		$bar = $this->output->createProgressBar(count($scan));
+		foreach($scan as $filename) {
+			$bar->advance();
+			$filename = config("app.path.paliword_index")."/".$filename;
+			if (is_file($filename)) {
+				Log::info("doing ".$filename);
+				DB::transaction(function ()use($filename) {
+				if (($fpoutput = fopen($filename, "r")) !== false) {
+						$count = 0;
+						while (($data = fgetcsv($fpoutput, 0, ',')) !== false) {
+							$newData = [
+								'id'=>$data[0],
+								'word'=>$data[1],
+								'word_en'=>$data[2],
+								'normal'=>$data[3],
+								'bold'=>$data[4],
+								'is_base'=>$data[5],
+								'len'=>$data[6],
+							];
+							WordIndex::create($newData);	
+							$count++;
+						}
+						Log::info("insert ".$count);
+					}
+				});				
+			}
+		}
+		$bar->finish();
+		$msg = "all done in ". time()-$startTime . "s";
+		Log::info($msg);
+		$this->info($msg);
         return 0;
     }
 }

+ 47 - 1
app/Console/Commands/InstallWordStatistics.php

@@ -3,6 +3,9 @@
 namespace App\Console\Commands;
 
 use Illuminate\Console\Command;
+use App\Models\WordStatistic;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Log;
 
 class InstallWordStatistics extends Command
 {
@@ -11,7 +14,7 @@ class InstallWordStatistics extends Command
      *
      * @var string
      */
-    protected $signature = 'command:name';
+    protected $signature = 'install:wordstatistics';
 
     /**
      * The console command description.
@@ -37,6 +40,49 @@ class InstallWordStatistics extends Command
      */
     public function handle()
     {
+		$startTime = time();
+
+		$info = "instert wordstatistics ";
+		$this->info($info.PHP_EOL);
+		Log::info($info);
+
+		#删除目标数据库中数据
+		WordStatistic::where('id', '>',-1)->delete();	
+
+		$scan = scandir(config("app.path.word_statistics"));
+		$bar = $this->output->createProgressBar(count($scan));
+		foreach($scan as $filename) {
+			$bar->advance();
+			$filename = config("app.path.word_statistics")."/".$filename;
+			if (is_file($filename)) {
+				Log::info("doing ".$filename);
+				DB::transaction(function ()use($filename) {
+				if (($fpoutput = fopen($filename, "r")) !== false) {
+						$count = 0;
+						while (($data = fgetcsv($fpoutput, 0, ',')) !== false) {
+							$newData = [
+								'bookid'=>$data[0],
+								'word'=>$data[1],
+								'count'=>$data[2],
+								'base'=>$data[3],
+								'end1'=>$data[4],
+								'end2'=>$data[5],
+								'type'=>$data[6],
+								'length'=>$data[7],
+							];
+							WordStatistic::create($newData);	
+							$count++;
+						}
+						Log::info("insert ".$count);
+					}
+				});				
+			}
+		}
+		$bar->finish();
+		$msg = "all done in ". time()-$startTime . "s";
+		Log::info($msg);
+		$this->info($msg);
+        return 0;
         return 0;
     }
 }

+ 3 - 0
app/Models/WordIndex.php

@@ -8,4 +8,7 @@ use Illuminate\Database\Eloquent\Model;
 class WordIndex extends Model
 {
     use HasFactory;
+	protected $fillable = ['id' , 'word' , 'word_en' , 'count' , 'normal' , 'bold' , 'is_base' , 'len'  ];
+
+	
 }

+ 2 - 0
app/Models/WordList.php

@@ -8,4 +8,6 @@ use Illuminate\Database\Eloquent\Model;
 class WordList extends Model
 {
     use HasFactory;
+	protected $fillable = ['sn','book' , 'paragraph', 'wordindex' , 'bold' , 'weight' ];
+
 }

+ 2 - 0
app/Models/WordStatistic.php

@@ -8,4 +8,6 @@ use Illuminate\Database\Eloquent\Model;
 class WordStatistic extends Model
 {
     use HasFactory;
+	protected $fillable = ['bookid','word' , 'count', 'base' , 'end1' , 'end2','type', 'length'];
+
 }

+ 15 - 2
change-logs.md

@@ -34,8 +34,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 - rename RPC_DOMAIN_NAME -> RPC_SERVER in config.sample.js
 - add RPC_SERVER to .env.example
 
-## [1.0.4] - 2022-01-19
+## [1.0.4] - 2022-01-21
 
 - add SNOWFLAKE to .env.example
-- add snowflake to database.php
+- add SnowFlake to config.sample.php
+- add SnowFlakeDate to config.table.php
 - add dependency godruoyi/php-snowflake
+
+## [1.0.5] - 2022-01-24
+
+- add 帮助文件路径 URL_HELP to config.dir.php
+- add 巴利语手册路径 URL_PALI_HANDBOOK to config.dir.php
+- add help & handbook link 
+
+## [1.0.6]- 2022-01-27
+
+- remove HELP_SERVER GRAMMAR_SERVER from .env.example
+- remove HELP_SERVER GRAMMAR_SERVER from config.sample.php
+- remove HELP_SERVER GRAMMAR_SERVER from config.sample.php

+ 2 - 0
config/app.php

@@ -247,5 +247,7 @@ return [
 		'pali_title' => public_path('pali_title'),
 		'paliword' => public_path('paliword'),
 		'paliword_book' => public_path('paliword')."/book",
+		'paliword_index' => public_path('paliword')."/index",
+		'word_statistics' => public_path('dependence')."/word_statistics/data",
 	],
 ];

+ 1 - 3
public/app/config.sample.js

@@ -11,6 +11,4 @@ var RPC_SERVER = "https://rpc.wikipali.org";
   |------------------------
 */
 
-var ASSETS_SERVER = "https://assets-hk.wikipali.org"
-var HELP_SERVER = "https://help-hk.wikipali.org"
-var GRAMMAR_SERVER = "https://grammar-hk.wikipali.org"
+var ASSETS_SERVER = "https://assets-hk.wikipali.org"

+ 0 - 2
public/app/config.sample.php

@@ -5,8 +5,6 @@
 
 define("RPC_SERVER","https://rpc.wikipali.org");
 define("ASSETS_SERVER","https://assets-hk.wikipali.org");
-define("HELP_SERVER","https://help-hk.wikipali.org");
-define("GRAMMAR_SERVER","https://grammar-hk.wikipali.org");
 
 /*
 电子邮件设置

+ 4 - 4
public/app/config.table.php

@@ -532,10 +532,10 @@ define("_TABLE_WORD_STATISTICS_", _PG_TABLE_WORD_STATISTICS_);
 
 */
 
-define("_FILE_DB_PALI_SENTENCE_", _SQLITE_DB_PALI_SENTENCE_);
-define("_TABLE_PALI_SENT_", _SQLITE_TABLE_PALI_SENT_);
-define("_TABLE_PALI_SENT_ORG_", _SQLITE_TABLE_PALI_SENT_ORG_);
-define("_TABLE_PALI_SENT_INDEX_", _SQLITE_TABLE_PALI_SENT_INDEX_);
+define("_FILE_DB_PALI_SENTENCE_", _PG_DB_PALI_SENTENCE_);
+define("_TABLE_PALI_SENT_", _PG_TABLE_PALI_SENT_);
+define("_TABLE_PALI_SENT_ORG_", _PG_TABLE_PALI_SENT_ORG_);
+define("_TABLE_PALI_SENT_INDEX_", _PG_TABLE_PALI_SENT_INDEX_);
 
 /*
 相似句

+ 3 - 2
public/app/dict/dict_lookup.php

@@ -107,8 +107,9 @@ $right_word_list = "";
 				}
 
 				
-                $query = "SELECT dict.id,dict.dict_id,dict.mean,info.shortname from " . _TABLE_DICT_REF_ . " LEFT JOIN info ON dict.dict_id = info.id where word = ? limit 30";
-                $Fetch = PDO_FetchAll($query, array($x));
+                //$query = "SELECT dict.dict_id,dict.mean,dn.shortname from " . _TABLE_DICT_REF_ . " LEFT JOIN "._TABLE_DICT_REF_NAME_." as dn ON dict.dict_id = dn.id where word = ? limit 30";
+
+				$Fetch = PDO_FetchAll($query, array($x));
                 $iFetch = count($Fetch);
                 $count_return += $iFetch;
                 if ($iFetch > 0) {

+ 1 - 0
storage/app/.gitignore

@@ -1,3 +1,4 @@
 *
 !public/
+!tmp/
 !.gitignore

+ 2 - 0
storage/app/tmp/.gitignore

@@ -0,0 +1,2 @@
+*
+!.gitignore

+ 1 - 1
v1/scripts/install.bat

@@ -20,5 +20,5 @@ php ./migrations/20211127214900-sent_sim_index.php
 php ../../public/app/fts/sql.php
 
 php ../../public/app/admin/word_index_weight_refresh.php 1 217
-php ./migrations/20211125155600_word_statistics.php
+
 net time \\127.0.0.1

+ 0 - 1
v1/scripts/install.sh

@@ -23,6 +23,5 @@ php ./migrations/20211127214900-sent_sim_index.php
 php ../../public/app/fts/sql.php
 
 php ../../public/app/admin/word_index_weight_refresh.php 1 217
-php ./migrations/20211125155600_word_statistics.php
 
 date